Panache
Panache

Reputation: 987

didFinishLaunchingWithOption not getting called when the action button of push notification is clicked

I am implementing Push Notification using Urban Airship library. I am able to receive push notifications from Test Push Notifications. Now when I click on View i.e. action button of the push notification alert, my app launches but unable to get the call back in didFinishLaunchingWithOption and applicationDidBecomeActive either. Here is what I am doing so far in my didFinishLaunchingWithOption,

// Check if App running in Simulator.
        [self failIfSimulator];

        NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

        if (remoteNotification != nil) {
            NSString *message = [remoteNotification descriptionWithLocale:nil indent: 1];
            NSLog(@"Message in didFinishLaunchingWithOptions: %@",message);
        } 

        //Init Airship launch options
        NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
        [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];

        // Create Airship singleton that's used to talk to Urban Airship servers.
        // Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
        [UAirship takeOff:takeOffOptions];

        // Register for notifications
        [[UIApplication sharedApplication]
         registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                             UIRemoteNotificationTypeSound |
                                             UIRemoteNotificationTypeAlert)];

Now when i receive any notification using Test Push and on clicking on View button my app gets launched but didFinishLaunchingWithOption is not getting called. AM I missing any thing? Also, I want to show my own ui when u View the notification.

Please guide me If I am missing any thing. Also some samples, links may be helpful. Thanks in advance...

Upvotes: 1

Views: 2209

Answers (1)

mattjgalloway
mattjgalloway

Reputation: 34902

Maybe the app is already launched? You need to also implement:

application:didReceiveRemoteNotification:

In there you will get the notification even when the app has already been launched.

Upvotes: 2

Related Questions