2013-03-19 57 views
0

我发送一个本地通知,一旦一个过程完成,它的行为就好了。本地通知问题

这是我didReceiveLocalNotification代码:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ 

    CounterViewController *counterVC = [CounterViewController sharedInstance]; 
    [counterVC notificationArrived]; 
} 

但是,当iPhone被锁定的那些行不叫......我能做些什么,使他们在后台运行?

回答

1

有两种方法来接收本地通知一个已经被您已经实现,而应用程序正在运行&第二个是当你的应用程序正在运行的背景时被调用didFinishLaunchingWithOptions你必须添加一些代码接受本地通知时调用.. ...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

// Override point for customization after application launch. 

// Add the view controller's view to the window and display. 


application.applicationIconBadgeNumber = 0; 

// Handle launching from a notification 
UILocalNotification *localNotif = 
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
if (localNotif) { 
    NSLog(@"Recieved Notification %@",localNotif); 
} 

return YES; 

}