简体   繁体   English

针对Cordova Android应用程序的地理围栏和推送通知

[英]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 - 我有一个cordova android应用程序,在其中需要以下内容-

  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. 对于地理围栏,我认为我可以使用Cordova Geolocation的WatchPosition方法。 Using this, whenever there is a change in position and when that position matches my Geofence, the mobile should receive a push notification. 使用此功能,只要位置发生变化并且该位置与我的Geofence相匹配,移动设备就应该收到推送通知。 I understand that using Watchposition I can get latitude and longitude values but how to check the geofence's radius??? 我了解使用Watchposition可以获得纬度和经度值,但是如何检查地理围栏的半径?

For push notifications I have a cordova plugin here 对于推送通知,我在这里有一个cordova插件

I need to know how to integrate this push notification to a geofence using watchPosition in Cordova. 我需要知道如何使用Cordova中的watchPosition将此推送通知集成到地理围栏。 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. 也许值得一看一下Haversine公式 ,您应该能够得出两点之间的距离。

There is an implementation of the functions written for Phonegap in this SO answer: 在此SO答案中有为Phonegap编写的功能的实现:

https://stackoverflow.com/a/17031284/147323 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.com和https://github.com/cowbell/cordova-plugin-geofence它可以使您做到这一点,即时通讯的工作是基于Transition,以便当用户进入该地理区域时自动在细分中输入用户并在退出时将其删除。 OneSignal has beaucoup API reference to make this super easy. OneSignal具有beaucoup API参考,使此超级简单。 Good Luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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