我需要后台进程(用于调用网络服务)在应用启动状态时调用 didReceiveLocalNotification:(UILocalNotification *)notification,如何做到这一点,请帮助我。
提前致谢
我试过这个:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
}
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
{
if (app.applicationState == UIApplicationStateInactive )
{
NSLog(@"app not running");
}
else if(app.applicationState == UIApplicationStateActive )
{
NSLog(@"app running");
}
}