Get the push notification token - iOS 10, Swift 3

后端 未结 9 890
深忆病人
深忆病人 2020-12-25 14:07

How to get the device token from new xCode 8, Swift 3 in iOS 10?

Here is the code to register notification:

<
9条回答
  •  难免孤独
    2020-12-25 14:43

    Faced the same problem, this is the only thing that helped me:

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let token = String(format: "%@", deviceToken as CVarArg)
            .trimmingCharacters(in: CharacterSet(charactersIn: "<>"))
            .replacingOccurrences(of: " ", with: "")
    }
    

提交回复
热议问题