Breaking News
Home / iOS / iOS Snippets / How to get Device token when registered for PushNotification in iOS?

How to get Device token when registered for PushNotification in iOS?

Solution

  1.   (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
  2. {
  3.     NSLog(@"My token is: %@", deviceToken);
  4.        
  5.  
  6.     NSString * deviceTokenString = [[[deviceToken description]
  7.                                  stringByTrimmingCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@"<>"]]
  8.                                 stringByReplacingOccurrencesOfString:@" "withString:@""];
  9.    
  10.    
  11.    NSLog@"Device Token set to %@",deviceTokenString);
  12. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger