How can I convert my device token (NSData) into an NSString?

后端 未结 30 1948
挽巷
挽巷 2020-11-28 18:31

I am implementing push notifications. I\'d like to save my APNS Token as a String.

- (void)application:(UIApplication *)application
didRegisterForRemoteNotif         


        
30条回答
  •  旧巷少年郎
    2020-11-28 19:27

    2020

    token as text...

    let tat = deviceToken.map{ data in String(format: "%02.2hhx", data) }.joined()
    

    or if you prefer

    let tat2 = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    

    (result is the same)

提交回复
热议问题