美文网首页
iOS 获取设备token、device token

iOS 获取设备token、device token

作者: GreenB | 来源:发表于2016-07-06 19:59 被阅读7984次

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{

NSLog(@"deviceToken=====%@",deviceToken);

NSString*device = [[[[deviceTokendescription]stringByReplacingOccurrencesOfString:@"<"withString:@""]stringByReplacingOccurrencesOfString:@" "withString:@""]stringByReplacingOccurrencesOfString:@">"withString:@""];

NSUserDefaults*defaults = [NSUserDefaultsstandardUserDefaults];

[defaultssetObject:deviceforKey:DEVICE_TOKEN];

[defaultssynchronize];

}

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo

{

NSLog(@"%@",userInfo);

[[NSNotificationCenterdefaultCenter]postNotificationName:@"ReceivePush"object:niluserInfo:userInfo];

}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error{

NSLog(@"Regist fail%@",error);

}

相关文章

网友评论

      本文标题:iOS 获取设备token、device token

      本文链接:https://www.haomeiwen.com/subject/ntwkjttx.html