Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

push notification - iphone Launch Options

im not getting any launch options after a push notification; heres the code i have but non of the NSLogs seem to print in the debug area.

UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

if (localNotif) {
    NSString *itemName = [localNotif.userInfo objectForKey:@"aps"];
    NSLog(@"Custom: %@", itemName);
} else {
    NSLog(@"//////////////////////////");

}

when i open the app (via pressing view on the push notification) it goes to the didReceiveRemoteNotification script, im not sure if thats meant to happen..

thanks for reading.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your application receives push notifications through multiple paths, depending on the state of your app when it is received.

If your app is not launched (not even suspended in background), the launchOptions will contain the notification payload (key UIApplicationLaunchOptionsRemoteNotificationKey).

If it is already running or suspended in background, the app will receive the notifications via application:didReceiveRemoteNotification: in your application delegate.

The process is the same for local notifications (UIApplicationLaunchOptionsLocalNotificationKey in application:didFinishLaunchingWithOptions: and application:didReceiveLocalNotification:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...