简体   繁体   English

ios后台服务以计算距离并通知用户

[英]ios background service to calculate distance and notify user

I'm using ios mapkit for my project. 我正在为项目使用ios mapkit。 Basically, I'm trying to notify the user when he arrives at a given location. 基本上,我试图在用户到达给定位置时通知用户。 What I do here is I get the distance to the destination and if it's somewhere around 20 meters I'm calling a REST API which will send a push notification to another user. 我在这里要做的是获得到目的地的距离,如果距离在20米左右,我正在调用REST API,它将向另一个用户发送推送通知。 This works fine if the app in the foreground. 如果应用程序在前台,则效果很好。 But how can I do this while the app is in the background? 但是,当应用程序在后台运行时,我该怎么做? I know there are background modes in the ios. 我知道ios中有后台模式。 But I can't figure out which mode going to fit here 但我不知道哪种模式适合这里

Thanks 谢谢

Having tested and deployed region monitoring in production code, I can tell you its bad for walking. 在生产代码中测试并部署了区域监视之后,我可以告诉您它对行走不利。 It relies on cell towers and the alerts are very flakey at fence sizes of less that 150-200 meters, which is a long way to walk. 它依靠手机信号塔,在栅栏尺寸小于150-200米的情况下,警报效果非常好,这是很长的路要走。 We initially tried 30 meters and the results were disastrous with tons of false negatives and a few false positives. 我们最初尝试了30米,结果是灾难性的,有大量假阴性和一些假阳性。 If you really want to detect 20 meters then you need to use GPS mode, which is drains the battery but its the only thing that has that kind of granularity. 如果您真的想检测20米,则需要使用GPS模式,该模式会耗尽电池电量,但它只有这种粒度。

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

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