首先,我在构造函数中初始化地理围栏并在成功初始化之后,在以下代码的帮助下创建地理围栏...

geofence.initialize().then(() =>{
            alert('Geofence Plugin Ready')
            this.addGeofence()
          },(err) => {
            alert(err)
          }) 

    addGeofence(){
    let fence = [
      {
        id: 'enter',
        latitude: 28.6016271,
        longitude: 77.3519364,
        radius: 1000,
        transitionType: 1,
        notification: {
          id: 1,
          title: 'You crossed a fence',
          text: 'You just arrived at ABC Pvt. Ltd.',
          openAppOnClick: true
        }
      }  ]
    this.geofence.addOrUpdate(fence).then(
      () => console.log('Geofence added'),
     (err) => console.log('Geofence failed to add')
    )

    this.geofence.getWatched().then(
      (res) => console.log('Geofence Watching  ::' + res),
      (err) => console.log('Geofence Error is  :  ' + err)
    )

    this.geofence.onTransitionReceived().subscribe((resp) => {
      console.log("geofence on transition received", resp);
    },(err) =>{
      alert('error'+err)
    })
  }

在这段代码中,我创建了一个围栏,纬度为28.6016271,经度为77.3519364,围栏半径为1000米 . 根据离子本地地理围栏的文件,当我进入这个围栏onTransitionReceived()方法调用并通知我文本“你刚刚到达ABC Pvt.Ltd . ”要么我的应用程序在后台或前台,但目前我没有收到通知,当我进入这个围栏 .