如果您的應用程序在後臺運行,並且您在LocalNotification橫幅竊聽,那麼你將被調用下面的方法:
-(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
的iOS 8之後:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
如果應用程序是不在後臺運行,您將收到通知:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if ([launchOptions valueForKey:@"UIApplicationLaunchOptionsLocalNotificationKey"]) {
// here you will get
}
的確定這如果應用程序被暫停,而不是運行,那麼應用程序將調用「didFinishLaunchingWithOption」,如果應用程序在後臺運行,那麼你將收到通知信息在「didReceiveLocalNotification」中。 – Pushpa