我正在构建一个在后台运行的应用程序,并在设备上跟踪大量位置更改。
是否可以将推送通知发送到设备,并让设备将当前的精确位置发送到服务器,而无需用户打开应用程序,以便在前景中运行?
此上一个所以答案似乎不再使用ios15。 应用程序:DidreceivereMoteNotification:FetchCompletionHandler
在我预先登上应用程序之前,似乎才被调用。有一种新方法可以实现此功能吗?
I'm building an app which is running in the background and tracking significant location changes on the device.
Is it possible to send a push notification to the device and have the device send the current precise location to a server without needing the user to open the app so it runs in the foreground?
This previous SO answer doesn't seem to work anymore with iOS15. application:didReceiveRemoteNotification:fetchCompletionHandler
does not seem to get called until I foreground the app. Is there a new method to achieve this functionality?
发布评论
评论(1)
有一个新功能以来iOS 15 :位置推动服务扩展(cllocationPushServiceExtension -docs 在这里)。这是一种在iOS设备上查询位置的电力有效方法,即使您的应用不运行,也是如此。
请深入研究文档,并按照步骤配置Xcode项目,添加位置推动服务扩展目标并实现位置推动功能。不要忘记适当的权利,并要求授权位置服务!
There is a new feature since iOS 15: Location Push Service Extension (CLLocationPushServiceExtension - docs here). It is a power efficient way to query locations on iOS devices, even when your app isn’t running.
Please dive in into the docs and follow steps to configure Xcode project, add a Location Push Service Extension Target and implement Location Push functionality. Don't forget about proper entitlements and to request authorization for Location Services!
https://developer.apple.com/documentation/corelocation/cllocationmanager/creating_a_location_push_service_extension