我想获取新事件的列表,因此,我需要在事件临近时连续打电话给服务部门。那么只有我可以通过API调用发送我的uid和eventide,然后后端团队会通知您临近事件。 因此,此服务如何在应用终止/终止/暂停时调用,因为这些事情在应用处于后台运行时有效。
答案 0 :(得分:0)
如果在应用程序流程中可行,则可以采用静默通知方式,每当需要调用方法时,您都可以向设备发送静默通知,
func registerForNotification() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in
guard error == nil else { return }
if granted {
//Register for RemoteNotifications. Your Remote Notifications can display alerts now :)
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
else {
//Handle user denying permissions..
}
}
providerDelegate = ProviderDelegate()
pushRegistry.delegate = self
pushRegistry.desiredPushTypes = [.voIP]
}
func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
//Here you get the token, send it to server.
}