Use*_*321 14
此方法将在调试模式下在控制台中打印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];
}
Run Code Online (Sandbox Code Playgroud)
如果您已实现此方法
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
}
Run Code Online (Sandbox Code Playgroud)
对于推送通知,您将获得设备令牌(此方法实际上是您在应用程序中实现的两种方法之一)
这可能会发现它很有用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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18798 次 |
| 最近记录: |