如何在一定距离下使用UILocalNotification?
我试图通过通知提醒用户,如果他到达半径为 100m 的某个注释(我创建了它们),他应该收到通知。
任何人都可以以正确的方式指导我,导致我无法找到任何东西:/。
谢谢很多人
I am trying to alert user with a notification that if he reaches with a radius say 100m of a certain annotation (i created them) he should receive a notification.
Can any direct me in d right way cause m not able fto find anythng :/.
Thanx alot guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了 fireDate 方法之外,
UILocalNotification
没有任何其他方法来显示它们。如果您想告诉用户他正在接近特定的 GPS 点,您需要让您的应用程序在后台接收位置更新。
您可以通过将
必需的后台模式
模式添加到信息plist并将其设置为用于位置更新的应用程序寄存器
来实现此目的。现在您的应用程序将继续在后台接收更新,这仅适用于 iPhone 3GS 及更高版本。
然后只需安排
UILocalNotification
并将 fireDate 设置为[NSDate date]
即可立即触发。UILocalNotification
does not have any other means to display them other the the fireDate method.If you want to tell the user that he is coming close to a specific GPS point you will need to let you app receive location updates when it is in the background.
You can do this by adding
Required background modes
mode to the info plist and set it toApp registers for location updates
.Now your app will keep receiving updates in background, this will only work on iPhone 3GS and up.
Then just schedule the
UILocalNotification
with a fireDate set as[NSDate date]
and it will fire immediately.