推送通知设备令牌?

如何从我的iPhone设备获取设备令牌?

此方法将在debugging模式下在控制台中打印deviceToken,如果您想查看UIAlert中也可以看到的设备令牌。

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"APN device token: %@", deviceToken); NSString *deviceTokenString = [NSString stringWithFormat:@"%@",deviceToken]; UIAlertView *deviceTokenAlert = [[UIAlertView alloc] initWithTitle:@"Device Token" message:deviceTokenString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; } 

如果你已经实现了这个方法

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

对于推送通知,你将得到设备令牌(这个方法实际上是你需要在应用程序中实现的两种方法之一)

这可能会发现它很有用http://urbanairship.com/docs/push.html

你也可以看看Iphone应用程序中的推送通知

希望这个对你有帮助。

此方法将在控制台中显示您的设备令牌。

 - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *str = [NSString stringWithFormat:@"%@",deviceToken]; NSString *newString = [str stringByReplacingOccurrencesOfString:@" " withString:@""]; newString = [newString stringByReplacingOccurrencesOfString:@"<" withString:@""]; newString = [newString stringByReplacingOccurrencesOfString:@">" withString:@""]; [[NSUserDefaults standardUserDefaults] setObject:newString forKey:@"deviceToken"]; NSLog(@"Your deviceToken ---> %@",newString); }