0

当我收到本地通知时,我想打开我的特定屏幕。目前在我的应用程序中,我同时使用了导航控制器和模型视图控制器,因此在导航控制器时,应用程序正在切换任何视图,但是当模型控制器退出时。它没有打开屏幕。请提出任何解决方案?

4

1 回答 1

1
There are two way to launch app when notification comes.

1-应用程序在后台运行。然后打开特定屏幕,如 - (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification {

   // write this line  
   [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];


}

in which controller class you are create notification.
- (void)viewDidLoad
 {
    [super viewDidLoad];

      [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(reloadTable)
                                             name:@"reloadData"
                                           object:nil];
   }

- (void)reloadTable
  {
     //  create object of that controller which your want to open.

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
     AddToDoViewController *cvc = (AddToDoViewController *)[sb    instantiateViewControllerWithIdentifier:@"AddToDo"];

    [self presentModalViewController:cvc animated:YES];

}

于 2013-07-11T12:22:58.910 回答