简体   繁体   中英

Geofencing and push notification for cordova android app

I've been working on this for last few days and am unable to get a proper implementation idea. I have a cordova android app in which I need the following -

  1. Send a push notification to the mobile based on a set of defined geofences.

For the Geofences, I thought I can use Cordova Geolocation's WatchPosition method. Using this, whenever there is a change in position and when that position matches my Geofence, the mobile should receive a push notification. I understand that using Watchposition I can get latitude and longitude values but how to check the geofence's radius???

For push notifications I have a cordova plugin here

I need to know how to integrate this push notification to a geofence using watchPosition in Cordova. Or kindly let me know is there any other way to implement this.

I checked something in SO here but there is no luck.

It might be worth looking at the Haversine formula with this you should be able to get the distance between the two points.

There is an implementation of the functions written for Phonegap in this SO answer:

https://stackoverflow.com/a/17031284/147323

Check out OneSignal.com and https://github.com/cowbell/cordova-plugin-geofence It allows you to do just that, what im doing is based on the Transition to automatically enter a user in a segment when they enter that geozone and remove them when they exit. OneSignal has beaucoup API reference to make this super easy. Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM