didReceiveIncomingPushWithPayload 应用程序被杀死时不工作
didReceiveIncomingPushWithPayload Not working when app is killed
我在 didReceiveIncomingPushWithPayload 方法中遇到了一个问题,因为它不会在应用 killed/terminated 时触发。但是当应用程序在后台时工作完美。
经过调查,我发现有些人建议使用新版本,因为这个版本已经被弃用了
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
DispatchQueue.main.async(execute: {() -> Void in
completion()
})
}
效果很好,但此方法仅适用于 iOS 11+,因此不适用于 iOS 9. 有什么建议吗?
我是这样理解的,它适用于 iOS 10 和 11。
//available(iOS, introduced: 8.0, deprecated: 11.0)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type) {
// no-op
}
}
//available(iOS 11.0, *)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
//your code
completion()
}
希望对您有所帮助。
我在 didReceiveIncomingPushWithPayload 方法中遇到了一个问题,因为它不会在应用 killed/terminated 时触发。但是当应用程序在后台时工作完美。
经过调查,我发现有些人建议使用新版本,因为这个版本已经被弃用了
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
DispatchQueue.main.async(execute: {() -> Void in
completion()
})
}
效果很好,但此方法仅适用于 iOS 11+,因此不适用于 iOS 9. 有什么建议吗?
我是这样理解的,它适用于 iOS 10 和 11。
//available(iOS, introduced: 8.0, deprecated: 11.0)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type) {
// no-op
}
}
//available(iOS 11.0, *)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
//your code
completion()
}
希望对您有所帮助。