[英]Push Notification Device Token?
如何從我的iPhone設備獲取設備令牌?
此方法將在調試模式下在控制台中打印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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.