0

當我得到本地通知時我想打開我的特定屏幕。 目前在我的應用程序中,我已經使用導航控制器以及模型視圖控制器,所以在導航控制器時,應用程序切換任何視圖,但是當模型控制器退出時。它不會打開屏幕。 Plz建議任何解決方案?本地通知和打開特定屏幕

回答

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

1-程序是在background.then打開特定屏幕運行像 - (無效)應用:(UIApplication的*)應用didReceiveLocalNotification:(UILocalNotification *)通知 {

// 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]; 

}