iOS 7中推送如何获得唯一不变的字符串?IMSI MCC MNC这些怎么获得?
现在那个获取deviceToken的方法被废弃掉了!
所以想要获取到唯一的"deviceToken"的备用方法可以是:获取手机的mac地址来达到目的
开源解决方案地址:UIDevice-with-UniqueIdentifier-for-iOS-5
该方案提供了两个方法:
uniqueDeviceIdentifier (返回MAC和CFBundleIdentifier的MD5值)
uniqueGlobalDeviceIdentifier(返回MAC的MD5值)
使用方法:
#import "UIDevice+IdentifierAddition.h"
NSLog(@"%@",[[UIDevice currentDevice] uniqueDeviceIdentifier]);
NSLog(@"%@",[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]);
使用这种方式获取到的token就是唯一的!
注册推送服务( [[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];),
appdelegate的回调里面可以获取devicetoken
(- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)pToken {
NSLog(@"regisger success:%@",pToken);
//注册成功,将deviceToken保存到应用服务器数据库中
}),就可以推送了,IMSI MCC MNC在apns中是不行的,如果你要用这些做唯一标识自己维护推送,那另说
推送到设备应该用deviceToken啊,为什么要UUID?UUID本身并不是唯一的。后面用CTTelephonyNetworkInfo获取