Error: [object Position error] transitionType | Geofence, geolocation

Every time I run this code on my phone, it first displays

Module cordova-plugin-geofence.TransitionType does not exist

and then when I close the message and try to run the app anyway, it displays

[object PositionError]

Here is the code: (I have commented some snippets because not sure if it is right)

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Geolocation } from '@ionic-native/geolocation';
import { Geofence } from '@ionic-native/geofence';
import { SMS } from '@ionic-native/sms';
import { ActivePage } from '../active/active';

  selector: 'page-home',
  templateUrl: 'home.html'

export class HomePage {

	radius: number = 100;
	error: any;
	success: any;

  constructor(public navCtrl: NavController, public geofence:Geofence, public geolocation: Geolocation, private SMS: SMS) {

document.addEventListener('deviceready', function () {
    // window.geofence is now available
    this.geofence.initialize().then(function () {
        console.log("Successful initialization");
    }, function (error) {
        console.log("Error", error);
}, false);
  	this.platform.ready().then(() => {
        () => console.log('Geofence Plugin Ready'),
        (err) => console.log('error is happening here')



  setGeofence(value: number) {

      enableHighAccuracy: true
    }).then((resp) => {
      var longitude = resp.coords.longitude;
      var latitude = resp.coords.latitude;
      var radius = value;

      let fence = {
          id: "myGeofenceID1", 
          latitude:       latitude, 
          longitude:      longitude,
          radius:         radius,
          TransitionType: 2, //see 'Transition Types' below

          () => this.success = true,
          (err) => this.error = "Failed to add or update the fence."

        /* this.geofence.onTransitionReceived().subscribe(resp => {
          this.SMS.send('+918277628369', 'The person has left');

        /* this.geofence.onTransitionReceived().subscribe( res =>{

          /*res.forEach(function(geo) {
this.SMS.send('+918277628369', 'The senior citizen under your charge has left the house! Please ensure they are safe.');
        (err) => console.log(err),
        ()    => console.log("done !")

    var phnum = document.getElementsByName("phnumber")

    this.geofence.onTransitionReceived().subscribe( res =>{

          res.forEach(function(geo) {
            this.SMS.send(phnum, 'The person has left');

        (err) => console.log(err),
        ()    => console.log("done !")

    }).catch((error) => {
      this.error = error;

Thanks for your help!

Edit: Here are screenshots of the errors.

Well, you have to wait on platform.ready before doing anythin on the plugins. So I would say the commented code is actually better then the other

Hey! Thanks for the reply!

I implemented your suggestion - now I get the error message “Failed to add or update the fence”, indicating that the process failed when I run the app on Chrome.

But on my phone, the error persists.

Module cordova-plugin-geofence.TransitionType does not exist shows when I open the app, and [object position error]when I actually test the app.

Sorry to be a bother, but do you have any other ideas as to what may be causing the error?

Thanks a lot…

Sorry, I have no experience with this plugin

But as you seem to be using android, I suggest using devtools to monitor console.logs and check what happens step-by-step…