Can't get iPhone device token

Posted by d.andreykiv on Stack Overflow See other posts from Stack Overflow or by d.andreykiv
Published on 2010-04-02T15:33:54Z Indexed on 2010/04/02 15:53 UTC
Read the original article Hit count: 772

Hi. I'm trying to get iPhone device token using following code

 
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    NSLog(@"Registering for push notifications...");    
 [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert];

}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken
{
 NSLog(@"Registered!@@");
}


- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
 NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error);
 if ([error code] != 3010) // 3010 is for the iPhone Simulator
 {
  // show some alert or otherwise handle the failure to register.
 }
}

but only getting "2010-04-02 18:23:35.434 Untitled[3133:207] Registering for push notifications..."

What I was doing wrong?

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about iphone