iOS13 中 FCM 的推送通知问题
Push Notification issue with FCM in iOS13
我正在使用 FCM 进行推送通知。我曾经使用以下方法刷新应用程序的内容
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
现在 iOS13 此方法不再触发。我也包含了 apns-push-type 和 apns-priority。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if #available(iOS 13.0, *) {
// your code
completionHandler(UIBackgroundFetchResult.newData)
} else {
}
}
- 还要在 FCM 上检查您的 APNS 证书,它必须在您当前使用的 XCode 版本
的钥匙串中提供 .p12 类型
我发现了问题。
UIApplication.shared.registerForRemoteNotifications()
每次发布都必须 运行。最好将它保留在 didFinishLoadingWithOptions 方法中。在我以前的版本中,我曾经第一次调用它,但看起来每次启动都必须调用它。
并确保也为通知和消息传递设置委托。
UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self
我正在使用 FCM 进行推送通知。我曾经使用以下方法刷新应用程序的内容
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
现在 iOS13 此方法不再触发。我也包含了 apns-push-type 和 apns-priority。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if #available(iOS 13.0, *) {
// your code
completionHandler(UIBackgroundFetchResult.newData)
} else {
}
}
- 还要在 FCM 上检查您的 APNS 证书,它必须在您当前使用的 XCode 版本 的钥匙串中提供 .p12 类型
我发现了问题。
UIApplication.shared.registerForRemoteNotifications()
每次发布都必须 运行。最好将它保留在 didFinishLoadingWithOptions 方法中。在我以前的版本中,我曾经第一次调用它,但看起来每次启动都必须调用它。
并确保也为通知和消息传递设置委托。
UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self