ios – 当用户退出地理围栏时触发事件

ios – 当用户退出地理围栏时触发事件,第1张

概述有没有办法在iOS设备的当前位置周围定义地理围栏(中心和半径),并让系统在设备退出地理围栏时触发我的应用程序中的回调功能?这个机制会唤醒一个封闭的应用吗? 我想避免广泛的GPS使用,所以我更喜欢定期GPS轮询的系统消息,即使以降低精度的代价. 您的解决方案是 Region Monitoring. In iOS, regions associated with your app are tracke 有没有办法在iOS设备的当前位置周围定义地理围栏(中心和半径),并让系统在设备退出地理围栏时触发我的应用程序中的回调功能?这个机制会唤醒一个封闭的应用吗?

我想避免广泛的GPS使用,所以我更喜欢定期GPS轮询的系统消息,即使以降低精度的代价.

解决方法 您的解决方案是 Region Monitoring.

In iOS,regions associated with your app are tracked at all times,
including when your app is not running. If a region boundary is
crossed while an app is not running,that app is @R_979_4404@ed into
the background to handle the event. Similarly,if the app is suspended
when the event occurs,it is woken up and given a short amount of
time (around 10 seconds) to handle the event.

每当应用程序请求区域监控时,iOS就会采取立场.您的应用程序注册了一些位置,并要求iOS监控该区域&在准确准确地进入或离开该区域时通知.

喜欢
CLRegion * region = [[CLCircularRegion alloc] initWithCenter:[location coordinates] radius:250.0 IDentifIEr:[[NSUUID UUID] UUIDString]];

现在iOS接受了这个请求&使用内部标识将其添加到区域监控的系统队列中.一旦设备进入该区域或退出该区域,iOS就会向应用程序发送通知以启动解雇代表.

– (voID)locationManager:(CLLocationManager *)manager dIDEnterRegion:(CLRegion *)region

– (voID)locationManager:(CLLocationManager *)manager dIDExitRegion:(CLRegion *)region

请注意,如果您的应用程序在后台运行,一旦设备进入/存在注册区域,iOS将使您的应用程序在后台启动.

这是FourSquare& amp; amp;其他类似的应用程序trIE执行大量的位置数据收集和将其发送到服务器&在很短的时间内为用户提供定制的消息.

总结

以上是内存溢出为你收集整理的ios – 当用户退出地理围栏时触发事件全部内容,希望文章能够帮你解决ios – 当用户退出地理围栏时触发事件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1057435.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存