2014-09-19 34 views
1

使用UIMutableUserNotificationAction如何使应用程序在前台编程

在应用程序的情况下,我开发我的iOS8上,应用一些LocalNotifications在后台运行,并在用户触摸这个UIMutableUserNotificationAction应用程序应该复出前景。

我该如何解决?

的事件UIMutableUserNotificationAction火灾是:

-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString 
*)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler 

回答

0

你应该实例化你的故事板和视图控制器应用:handleWithIdentifier ..和视图控制器推到导航控制器,如果你有一个或设为根视图控制器,如果你没有。

您也可以使用application:didReceiveLocalNotification:方法。

事情是这样的:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 
    { 
      MyViewController *presenterVC = [_storyBoard instantiateViewControllerWithIdentifier:@"MyViewController"]; 

      [_navigationController pushViewController:presenterVC animated:NO];  

      self.window.rootViewController = _navigationController; 

    } 
+0

难道没有为我工作。我没有使用Storyboard。 'TabViewController * tabViewController = [TabViewController new]; self.window.rootViewController = tabViewController;'并使用'[self.window makeKeyAndVisible];'也没有效果。 – blub 2014-09-22 09:58:30

+0

您正在使用笔尖吗? – Razvan 2014-09-22 10:54:39

+0

不,只有硬编码的东西。我发现很多帖子,用户表示这是不可能的(例如LocalNotification),从而使应用程序以编程方式回到前台 - >它需要用户交互性。但是我正在使用用户与之交互的新iOS8 _interactive notifications_。所以我会说它应该是可能的......但是如何? – blub 2014-09-22 13:15:11

相关问题