I've got a tabbed application that uses Push Notifications (PN).
Whenever a PN is received, I want it to automatically open tab 2 (index 1), both if the app is opened or not.
For this I intercept the PN in AppDelegate.m>didReceiveRemoteNotification, and call the "OpenEventTab" in FirstViewController:
AppDelegate.m
FirstViewController.m
Using NSLog I've realized that the "OpenEventTab"-method is in fact called each time a PN is received, but despite this the next tab is not opened.
Calling the "OpenEventTab" from a button from within FirstViewController does however show that the function does indeed work, and promptly opens the next tab.
So you can probably appreciate why I'm a bit confused at this behavior. Does anybody have an explanation and hopefully a solution to this?
Thanks,
Dan
Whenever a PN is received, I want it to automatically open tab 2 (index 1), both if the app is opened or not.
For this I intercept the PN in AppDelegate.m>didReceiveRemoteNotification, and call the "OpenEventTab" in FirstViewController:
AppDelegate.m
Code:
...
#import "FirstViewController.h"
...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
FirstViewController *firstView = [[FirstViewController alloc] init];
[firstView OpenEventTab];
NSLog(@"OpenEventTab called");
}
FirstViewController.m
Code:
- (void)OpenEventTab
{
self.tabBarController.selectedIndex = 1;
NSLog(@"OpenEventTab executed");
}
Using NSLog I've realized that the "OpenEventTab"-method is in fact called each time a PN is received, but despite this the next tab is not opened.
Calling the "OpenEventTab" from a button from within FirstViewController does however show that the function does indeed work, and promptly opens the next tab.
So you can probably appreciate why I'm a bit confused at this behavior. Does anybody have an explanation and hopefully a solution to this?
Thanks,
Dan