Push Notification Device Token?

| | August 10, 2015

How to get Device Token from my iPhone Device?

3 Responses to “Push Notification Device Token?”

  1. This method will show your device token in console.

    - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
        NSString *str = [NSString 
        NSString *newString = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
        newString = [newString stringByReplacingOccurrencesOfString:@"<" withString:@""];
        newString = [newString stringByReplacingOccurrencesOfString:@">" withString:@""];
        [[NSUserDefaults standardUserDefaults] setObject:newString forKey:@"deviceToken"];
        NSLog(@"Your deviceToken ---> %@",newString);
  2. 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"
  3. 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.

Leave a Reply