【问题标题】:Open specific view controller on click of local notification, if app is in foreground?如果应用程序在前台,单击本地通知打开特定的视图控制器?
【发布时间】:2016-04-08 11:09:58
【问题描述】:

我试图在单击本地通知时打开特定的视图控制器,如果应用程序在后台,我无法这样做,因为我在 applicationDidBecomeActive 方法中没有 [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];。如果可以的话请帮忙,在此先感谢。

【问题讨论】:

  • stackoverflow.com/a/15502253/1850983 检查上面的链接。它将帮助您解决问题。
  • @PayalManiyar 感谢您的回答,如果应用程序在前台,我想这样做,如果应用程序不在前台,您上面提到的链接很好。我怎么知道用户点击了通知,因为不会调用 didFinishLaunchingWithOptions。
  • 我已经给出了答案。请点赞。
  • 谢谢,也请为这个问题投票。
  • 抱歉,我没有遇到这个问题。

标签: ios objective-c uiviewcontroller notifications uilocalnotification


【解决方案1】:

喜欢

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        yourViewController *obj=[storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerStoryboardID"];
       // [self.window.rootViewController.navigationController pushViewController:obj animated:YES];
          self.window.rootViewController = obj;

更新

  - (void)applicationDidBecomeActive:(UIApplication *)application {
 
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MapViewController *obj=[storyboard instantiateViewControllerWithIdentifier:@"Map"];
// [self.window.rootViewController.navigationController pushViewController:obj animated:YES];
self.window.rootViewController = obj;



}

更新1

您可以在此处获取本地通知操作

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

完整教程见this

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-04-23
  • 2013-03-08
  • 1970-01-01
  • 2020-11-29
  • 1970-01-01
  • 2018-10-03
  • 2019-05-04
  • 2018-07-17
相关资源
最近更新 更多