码迷,mamicode.com
首页 > 编程语言 > 详细

swift 获取推送deviceToken

时间:2018-05-04 14:06:18      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:ring   两种方法   for   format   AC   cin   $0   cat   ESS   

升级swift3以后,在使用didRegisterForRemoteNotificationsWithDeviceToken这个方法的时候返回的deviceToken的数据类型为Data,打印出来的deviceToken值是“32byte ” 

下面两种方法转打印 deviceToken 

 let device = NSData(data: deviceToken)

   let deviceId = device.description.replacingOccurrences(of:"<", with:"").replacingOccurrences(of:">", with:"").replacingOccurrences(of:" ", with:"")

   print("我的deviceToken:\(deviceId)")

或者

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

    print(message: str)

swift 获取推送deviceToken

标签:ring   两种方法   for   format   AC   cin   $0   cat   ESS   

原文地址:https://www.cnblogs.com/zuidap/p/8989776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!