0

lorsque j'obtiens une notification locale Je souhaite ouvrir mon écran spécifique. actuellement dans mon application j'ai utilisé à la fois le contrôleur de navigation ainsi que le contrôleur de vue de modèle de sorte qu'au moment du contrôleur de navigation, l'application est en train de changer n'importe quelle vue, mais quand le contrôleur de modèle sort. il n'ouvre pas l'écran. Plz suggère une solution?Notification locale et Ouvrir l'écran spécifique

Répondre

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

1- application est en cours d'exécution dans l'écran spécifique ouvert background.then comme - (void) demande: (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]; 

}