whitebear
whitebear

Reputation: 12457

Get push notification as background app on iOS

I am making a certain application.

Which has these functions.

1 This application has push notification.

2 This application can stock the push notification log when it is active.

3 This application can stock the push notification log when it is not active.

1,2 is OK for me. 1 is normal, 2 is accomplished by push notification callback.

However 3...?

I guess on Android background job works and get the notification.

but is it impossible on iOS?

Upvotes: 0

Views: 182

Answers (2)

alx
alx

Reputation: 74

In addition to the previous answer: about didFinishLaunchingWithOptions. This only works when the program is launched by clicking on the notification/push message window. But if you run the app directly, by clicking on the app icon, even when the notification/push message arrives, you will not receive any data in launchOptions about push message. So about the paragraph 3: you can know it only if user tap on push message window/bar.

Upvotes: 1

Rajeev Singh
Rajeev Singh

Reputation: 198

When the application is not active, you can handle the push notification using didFinishLaunchingWithOptions delegate method:

   UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (localNotif) {
NSString *json = [localNotif valueForKey:@"data"];
// Parse your string to dictionary
}

Upvotes: 0

Related Questions