views:

193

answers:

1

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?

A: 

Are you running this in the simulator? See http://stackoverflow.com/questions/1811900/can-we-check-push-notification-in-simulator

Joshua Nozzi