Can UILocalNotification be used to wake up a task that is in the background

自作多情 提交于 2019-11-30 22:16:34

The user has a couple of choices: #1) Do they want to see a notification for your app. #2) If notifications are enabled for your app, do they want to click on your notification to launch your app. If they do accept notifications and open your notification while your app is in the background, application:didReceiveLocalNotification is called. To be clear, the user has to accept the notification (such as sliding the slider underneath the notification)... otherwise NOTHING is called.

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    NSLog(@"%@", notification);
}

If your app has been terminated application:didFinishLaunchingWithOptions: is called -

- (BOOL)application:(UIApplication *) 
application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions {
    UILocalNotification *theNotification = 
      [launchOptions 
        objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    NSLog(@"%@", theNotification);

    return YES;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!