【问题标题】:Push Notification issue with FCM in iOS13iOS13 中 FCM 的推送通知问题
【发布时间】:2019-10-10 11:00:21
【问题描述】:

我正在使用 FCM 进行推送通知。我曾经使用以下方法刷新应用程序的内容

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

现在在 iOS13 中这个方法不再触发了。我也包括了 apns-push-type 和 apns-priority。

【问题讨论】:

  • 是“didReceiveRegistrationToken”还是“didRegisterForRemoteNotificationsWithDeviceToken”方法调用?尝试使用最新的 xcode 11 构建新的 iPA。
  • 是的。他们工作正常
  • 如何将您的 APN 令牌转发给 FCM?你是依靠 FCM swizzling 还是手动转发?
  • 它与 FCM 混合

标签: swift firebase firebase-cloud-messaging ios13


【解决方案1】:

我发现了问题。

UIApplication.shared.registerForRemoteNotifications() 

这必须在每次启动时运行。最好将其保留在 didFinishLoadingWithOptions 方法中。在我以前的版本中,我曾经第一次调用它,但看起来每次发布都必须调用它。

并确保也为通知和消息设置代理。

UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self

【讨论】:

  • didFinishLoadingWithOptions
  • 这真的救了我的命!
  • 还救了我的命!
【解决方案2】:
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 证书,它必须 .p12 类型必须在您用于当前 XCode 版本的钥匙串中可用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 2017-12-09
    • 1970-01-01
    • 2018-03-22
    • 2019-07-19
    • 2020-04-21
    • 2018-06-24
    相关资源
    最近更新 更多