Hi all,
I‘m trying to get geofence Plugin to work. I want to be notified via notification when I approach a specific Location. I‘m using following code
setGeofence(value: number) {
Geolocation.getCurrentPosition({
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,
notification: { //notification settings
id: 1, //any unique ID
title: 'You crossed a fence', //notification title
text: 'You just arrived to Gliwice city center.', //notification body
openAppOnClick: true //open app when notification is tapped
}
}
Geofence.addOrUpdate(fence).then(
() => this.success = true,
(err) => this.error = "Failed to add or update the fence."
);
}).catch((error) => {
this.error = error;
});
}
But I do Not get the notification when I lease or approach the Location. When will the notification be Sent? Do I need additional plugins?
Thanks for any help
Timo