在iOS 13及更高版本中未收到来自Firebase的推送通知

未从Firebase在App中收到推送通知。 吊舱详细信息: 这些是我使用的依赖项:

Firebase(6.10.0)

FirebaseAnalytics(6.1.3)

FirebaseAnalyticsInterop(1.4.0)

FirebaseAuth(6.3.0)

FirebaseAuthInterop(1.0.0)

FirebaseCore(6.3.1)

FirebaseCoreDiagnostics(1.1.1)

FirebaseCoreDiagnosticsInterop(1.0.0)

FirebaseDatabase(6.1.1)

FirebaseInstanceID(4.2.5)

FirebaseMessaging(4.1.6)

iOS 12及以下版本收到的Swift 5.1推送通知。但是iOS 13没有收到任何推送通知。云发送成功消息以进行推送通知。

func authForRemoteNotificationsIn(_ application: UIApplication) {

    // Verify the remote notification registration status
    guard !application.isRegisteredForRemoteNotifications || UserDefaults.fcmToken.isEmpty else { return }

    /**
     Specify the notification options
     * Disbled sound: Silent notifications are more helpful the user
     */
    let authOptions: UNAuthorizationOptions = [.badge]
    // Requset the authorization
    UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { (_,error) in

        // Validate the request status
        guard let error = error else { return }
        print(error.localizedDescription)
    }

    // Request device token
    application.registerForRemoteNotifications()
}


func application(_ application: UIApplication,didRegisterForRemoteNotificationsWithdevicetoken devicetoken: Data) {
    print(#function)

    Messaging.messaging().delegate = self
    Messaging.messaging().isAutoInitEnabled = true
    Messaging.messaging().apnsToken = devicetoken
}
asdfg123321123321 回答:在iOS 13及更高版本中未收到来自Firebase的推送通知

您可以检查如何接收设备令牌吗?对于iOS 13,它已更改,因此您可能在API上注册了不受支持的格式。

选中this approach.

本文链接:https://www.f2er.com/3159935.html

大家都在问