You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm creating an Ionic app in which I use geofences to read information aloud about sights the user passes, and also to read guidance instructions (like Google Maps) for the user along the route.
Therefore I have two types of geofences - sights with radius 100m and directions with radius 50m. They are being added in the exact same way, and the addOrUpdate() method is succesful in both cases. However, only the directions geofences are being registered by onTransitionReceived().
The directions geofences are being created from an array of directions received from a Google DirectionsService response. The sights geofences are being created from an array of sights retrieved from a previous page in the app.
The only way I can make it work for the sights geofences is if I first format the properties I need into an array and then create and add the fences from it.
This seems very strange to me since the added geofences look identical when printed to the console.
I'm creating an Ionic app in which I use geofences to read information aloud about sights the user passes, and also to read guidance instructions (like Google Maps) for the user along the route.
Therefore I have two types of geofences - sights with radius 100m and directions with radius 50m. They are being added in the exact same way, and the addOrUpdate() method is succesful in both cases. However, only the directions geofences are being registered by onTransitionReceived().
The directions geofences are being created from an array of directions received from a Google DirectionsService response. The sights geofences are being created from an array of sights retrieved from a previous page in the app.
The only way I can make it work for the sights geofences is if I first format the properties I need into an array and then create and add the fences from it.
This seems very strange to me since the added geofences look identical when printed to the console.
Here is how I do it:
In constructor:
geofence.removeAll().then(()=>{ console.log('all geofences removed'), (err)=>{ console.log(err); } });
geofence.initialize().then(()=>{ console.log('geofence plugin ready'), (err)=>{ console.log(err); } });
Adding geofences in .ts file:
`
private addSightGeofences() {
let fences = [];
}
`
`addDirectionsGeofences() {
let fences = [];
}`
Then the call to onTransitionReceived() also in .ts file:
addGeofenceTransitions() { this.geofence.onTransitionReceived().subscribe((res) => { console.log(res); res.forEach((f) => { console.log(f); if (f.notification.data.isSight == true) { console.log('sight geofence reached'); this.sightSpeech(f.notification.data); this.updateDirectionsGeofences(); } else { console.log('directions geofence reached'); this.directionsSpeech(f.notification.data.instructions, f.notification.data.value); } }); }); console.log('geofence transitions added'); }
The text was updated successfully, but these errors were encountered: