Swift:firebase didRegisterForRemoteNotificationsWithDeviceToken在某些设备上不起作用

时间:2018-07-11 12:37:19

标签: ios swift firebase remote-notifications

我的代码:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print("Message: \(deviceToken)")
}

iphone 8 plusiphone 6打印设备令牌上,但在iphone 6s上无效

iphone 8 plusiphone 6s的版本是11.4

结果iphone 8 plusiphone 6收到通知,但iphone 6s没有收到

我的代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()

        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().delegate = self

            let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in })

        } else {
            let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
        }

        application.registerForRemoteNotifications()

        if((Messaging.messaging().fcmToken) != nil){
            AppDelegate.USERTOKEN = (Messaging.messaging().fcmToken)!
        }

        print("Message APP: \(AppDelegate.USERTOKEN)")

        return true
    }

注意:print("Message APP: \(AppDelegate.USERTOKEN)")适用于所有设备并打印令牌。

0 个答案:

没有答案