更新时间:2022-12-27 09:31:37
是的,(在大多数情况下)可以正常工作,前提是您正确设置了所有内容并获得了权限.您的应用需要至少启动1次,才能订阅更新.
Yes, it works (most of the time), if you set up everything correctly and have the permissions. Your app need's to be launched at least 1 time, so it can subscribe to the updates.
对于后台获取,请在didFinishLaunching
方法中设置UIApplication.shared.setMinimumBackgroundFetchInterval(3600)
,实施performFetchWithCompletionHandler
方法,并在后台模式下启用后台获取.
注意尽快执行此操作,并尽快调用completionHandler.
For background fetch, set UIApplication.shared.setMinimumBackgroundFetchInterval(3600)
at the didFinishLaunching
method, implement the performFetchWithCompletionHandler
method, and enable the Background Fetch in the Background Modes.
Pay attention to do it as quickly as possible, and call the completionHandler as soon as possible.
Read more on Updating Your App with Background App Refresh here
对于通知更新,还必须将CLLocationManager
对象的allowsBackgroundLocationUpdates
属性设置为true
,并在后台模式下启用位置更新.
For notification updates, you must also set the allowsBackgroundLocationUpdates
property of your CLLocationManager
object to true
, and enable the Location updates in the Background Modes.