Search code examples
iphoneios6devicetoken

how to send the device token to server in ios6?


I want to send the device token to server in my application. I am using following method to retrieve the device token.

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
     NSLog(@"deviceToken: %@", deviceToken);
}

but not worked in ios6. How can do this?


Solution

  • Have you written this line

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    

    inside this function,

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    It should work in iOS 6 if you have done this.