Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229279

Multiple Geofence of same location

$
0
0

I have a multiple geofencing in my project. I check the 10KM and 3KM of the same location.
when I on the 3KM range app notify me both notification message.
Actually, i need when in the range of 10 km(between 10KM and 3KM ) notify message A and when in the range of 3 km(between 3KM and 0KM ) notify message B.
no need for both messages when in range of 3KM.
How I can do this.

my Code:


 private addGeofence() {
    let fence = [
      {
      id: '69ca1b88-6fbe-4e80-a4d4-faizy4d3748acdb', //any unique ID
      latitude: 8.556498, //center of geofence radius
      longitude: 76.881820,
      radius: 10000, //radius to edge of geofence in meters
      transitionType: 1, //see 'Transition Types' below
      notification: { //notification settings
        id: 121212122, //any unique ID
        title: 'Message 1 ', //notification title
          text: 'You are on the 10 KM range', //notification body
        openAppOnClick: true //open app when notification is tapped
      }
    },
      {
        id: '69ca1b88-6fbe-4e80-a4d4-jhdsfjhfdki', //any unique ID
        latitude: 8.556498, //center of geofence radius
        longitude: 76.881820,
        radius: 3000, //radius to edge of geofence in meters
        transitionType: 1, //see 'Transition Types' below
        notification: { //notification settings
          id: 54575514, //any unique ID
          title: 'Message 2 ', //notification title
          text: 'You are on the 3 KM range', //notification body
          openAppOnClick: true //open app when notification is tapped
        }
      },
    ]

    this.geofence.addOrUpdate(fence).then(
      () => console.log("Geofence added"),
      (err) => console.log(err)
    );
  }

Viewing all articles
Browse latest Browse all 229279

Trending Articles