Sjakelien
Sjakelien

Reputation: 2317

didFinishLaunchingWithOptions remote notification empty on App Launch

I am implementing Push Notification in my app, and everything works just fine when the app is open: when a Notification is received, my method [self processRemoteNotification:pushNotification] fires off as expected. Now I want the same method to be called, when the app is receiving a remote notification, when it is NOT running. For that, I have the following code:

- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSDictionary* pushNotification =
    [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (pushNotification) {
        [self processRemoteNotification:pushNotification];
    }
    return YES;
}

I'm not really sure how to test this though.

What I did is

  1. kill the app on the device
  2. send a notification to the app
  3. wait until the device displays a badge & notification
  4. start the app on the device from Xcode

In the above method, I have put a break point. Somehow, the condition if (pushNotification) is not met, and my [self processRemoteNotification:pushNotification] is not fired.

What am I doing wrong?

Upvotes: 0

Views: 418

Answers (1)

graver
graver

Reputation: 15213

You need to start the app by sliding the notification from left to right on the lock screen or from the notification centre.

Upvotes: 1

Related Questions