Apple Push-Notable for callback didRegisterForRemoteNotificationsWithDeviceToken

I was just trying to get DeviceToken from my iPhone app using Apple Push Notification Service. At the moment I don't have a server side implementation. I created APP id, got SSL certificate, Provision profile with APN and called

- (void)applicationDidFinishLaunching:(UIApplication *)application {
//view init and add sub view to window
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}

      

method. When I launch the app, it opens an action window to allow Push Notification (means my APN registration request is working), but my callback fails. Neither didRegisterForRemoteNotificationsWithDeviceToken nor didFailToRegisterForRemoteNotificationsWithError are called ? can anyone help me solve the problem? Below are my callbacs for reference.

    - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {

            UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient" message:@"Entered into Error Method" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [myAlert show];
            [myAlert release];
            NSLog(@"Error in registration. Error: %@", err);

        }
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
    UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient" message:@"Got the deviceToken..!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [myAlert show];
    [myAlert release];        
}

      

+2


source to share


4 answers


The app should use:

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

      



not

- (void)applicationDidFinishLaunching:(UIApplication *)application

      

+3


source


I found out that PUSH notifications require port 5223 to be open on your network (if you are using WIFI) or otherwise a cellular data connection.



I faced the same problem on my home network and had to open the port manually on my wireless router.

+2


source


I had the same and literally spent hours trying to figure this out. Ultimately, I figured the iPod touch simply couldn't connect to Apple to get the device token, but that had nothing to do with any firewall. Instead, the problem was creating some sort of (TLS?) Encrypted connection in conjunction with the device clock, which was reset somewhere around 1970 .

Time update fixed. Hope this helps someone out there :).

0


source


The callbacks seem fine as you are saying that you should receive the callback shortly after the registration call is made (from anywhere).

This seems like a silly question, but to be sure you are delegating methods to your application's delegation class?

If so, I just don't understand why your methods won't get called. I see NSLog instructions there, but did you actually try to set a breakpoint on recording? And you are testing a device, not a simulator, right?

-1


source







All Articles