After the application receives a push notification, I would like to change the names of some buttons on my main ViewController . To achieve this behavior, I rewrote the application: didReceiveRemoteNotification: method in my case to re-create the UINavigationController instance with the controller that I would like to update as its root view controller, setting the button names to whatever I want:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.welcomeViewController]; [self.window setRootViewController:navController]; [self.welcomeViewController.buttonToUpdate setTitle: @"Updated Text" forState: UIControlStateNormal]; }
Although this may not be the best solution (maybe I could completely forget the UIButtons and force the view controller to use the UITableView with its rows acting like buttons?), But it works for the following scenarios:
1) The application is in the foreground. The message "Push alert alert" appears, the user touches "OK", the view is updated perfectly.
2) The application is in the background / closed. The device is in lock mode. Push notifications are received, the user unlocks the device, the application loads, the viewing is also perfectly updated.
The problem occurs when the user uses another application, for example, and sends a notification, but the user opens the NOT application through a push notification, but by clicking the application icon. In this case, application: didReceiveRemoteNotification: does not seem to be called, and the representation in questions is never updated.
Hope my explanation is clear. I am open to suggestions on various approaches or how to handle this last scenario using my approach.
Thanks!
source share