3 Replies
      Latest reply on Aug 17, 2016 8:55 AM by sleipn1r
      sleipn1r Level 1 Level 1 (0 points)

        hi,

         

        since Xcode beta 6 Appdelegate method after register

        Data with Token is nil,but Data contains 32Bytes so i need my token

         

        my register in


        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {

           

                let center = UNUserNotificationCenter.current()

                center.requestAuthorization(options: [.alert, .sound]) { (granted, error) in

                  

                }

              

                UIApplication.shared.registerForRemoteNotifications()

         

        return true

        }


        is done



        // delegate call function


        func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

            

        // deviceToken contains 32Bytes but i want

        // a String like this

        // <9f26d46d c37a473c 4dd209d5 8684fb62 bfedbe66 24dca86b 885ac856 68521db9>

        // any cast dit not work to String

         

         

        // print(deviceToken.debugDescription) is nil


        print(deviceToken.description) is nil

         

        let token = String(data: deviceToken), encoding: String.Encoding.utf8)

         

        // token is nil


        print (token) //is nil

         

         

        // for test only

        print(deviceToken.base64EncodedString()) // containsData

         

        //doSomethingWithToken(token)

         

         

        }

         

        thanks