Getting Remote Notification Device Token in Swift 4?

前端 未结 8 2354
梦谈多话
梦谈多话 2021-02-20 06:59

I am using this code to get the Notification Center Device token.

It was working in Swift 3 but not working in Swift 4. What changed?

if #available(iOS 1         


        
8条回答
  •  走了就别回头了
    2021-02-20 07:40

    You can get the device token like this:

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let token = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
        print("Device Token : ",token)
    }
    

提交回复
热议问题