使用swift3.0集成友盟推送卡在获取device_token这一步上了
//正常OC代码这样获取在 dIDRegisterForRemoteNotificationsWithDevicetoken 中添加如下语句NSLog(@"%@",[[[[devicetoken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""]);
而转成swift3.0,一开始我是这么写的
let token: String = devicetoken.description.replacingOccurrences(of: "<",with: "").replacingOccurrences(of: ">",with: "").replacingOccurrences(of: " ",with: "")//结果打印出来的值都是32bytes
网上找了好久才找到一个答案,感谢博主
swift3升级后获取deviceToken打印为32bytes处理
//将Data转化为NSData就行了let device = NSData(data: devicetoken)let deviceid = device.description.replacingOccurrences(of:"<",with:"").replacingOccurrences(of:">",with:"").replacingOccurrences(of:" ",with:"")总结
以上是内存溢出为你收集整理的swift3.0获取友盟device_token全部内容,希望文章能够帮你解决swift3.0获取友盟device_token所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)