【发布时间】:2016-11-07 13:25:01
【问题描述】:
我希望你们能帮助我,因为我的大脑因思考而燃烧:D。 我想通知用户,例如每 100 米。但我不想更改位置服务的刷新。有一个简单的方法,但我不喜欢它。我认为有更好的解决方案。 到目前为止我所做的(那是伪代码!)这在 didUpdateLocation 中调用
//We want notify User but only 5 times during the movement
if distanceToReport < settedDistance {
//Store that first Notification is fired
if !firstNotificationFired {
self.notifyUser(report: report)
}
if firstNotificationFired && distanceToReport <= 400 {
//Store that second Notification is fired
self.notifyUser(report: report)
} else if secondNotificationFired && distanceToReport <= 300 {
//Store that third Notification is fired
} else if thirdNotificationFired && distanceToReport <= 200 {
//Store that fourth Notification is fired
} else if fourthNotifiationFired && distanceToReport <= 100 {
//Store that fifth Notification is fired
}
}
还有比这更好更有效的方法吗?或者有什么数学或算法可以提供帮助?
到目前为止谢谢。
【问题讨论】:
标签: ios swift notifications location cllocationmanager