我有一个简单的地理围栏演示应用程序,该应用程序在关闭/关闭时也能工作。现在,当用户安装了应用程序并杀死它时,地理围栏仍然可以正常工作。当用户到达设定的区域时;didEnterLocation";正在做两件事。1.本地推送通知用户在Region 2中。向用户默认写入一个简单字符串";输入位置";。
我有点困惑,因为当应用程序完全失效时,我没想到能够执行代码(在didEnterLocation上,推送通知除外(。
我的问题是:任何人都有执行代码的可能性吗?当用户进入位置时,我可以进行网络请求吗?这是公认的bij苹果吗?
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
scheduleLocalNotification(alert: "didEnterRegion")
print("did enter location")
//save data to userdefaults
UserDefaults.standard.set("write something over here", forKey: "location")
//would it be possbile to do a network request over here ? and is this accepted bij apple
}
如果您的应用程序可以在后台运行。在这里打网络电话是合法的。
它就像一个后台提取(在后台模式下(。该应用程序被系统唤醒,系统可能有30秒的时间来做少量的工作。但是,当应用程序在后台运行时,要小心高CPU使用率。
- 请求始终授权
- 设置位置更新的背景模式
- 后台提取设置