iOS 获取设备token、device token

- (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)