How to get Device Token from my iPhone Device?
This method will show your device token in console.
- (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);
}
If you have implemented this method
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
}
for Push Notification then you will get the device token (This method is actually one of the two methods that you require to implement in the application)
This might find it useful http://urbanairship.com/docs/push.html
you can also look at Push Notification in Iphone application
I hope you find this useful.
this method will print the deviceToken in console in debug mode, if you want to see the device token you can see in UIAlert also.
- (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];
}