I receive a pust notification and push a view controller based on the data i get in push.
I do it like this:
UINavigationController *navVc=(UINavigationController *) self.window.rootViewController;
PictureTakeVC *pvc=[[PictureTakeVC alloc] init];
[navVc pushViewController:pvc animated:NO];
It works, but the view controller that was opened before i pressed home button shows for a moment.
I also tried this but it happens the same:
PictureTakeVC *pvc=[[PictureTakeVC alloc] init];
NSArray *vcs=[[NSArray alloc] initWithObjects: pvc, nil];
UINavigationController *navVc=(UINavigationController *) self.window.rootViewController;
navVc.viewControllers=vcs;
self.window.rootViewController = navVc;
How to push vc didReceiveRemoteNotification so that it opens immediatly and no other vc is shown for a moment?
As you said “but the view controller that was opened before i pressed home button shows for a moment.”,
The reason is not the code, but the iOS system.
It captures screenshot of the screen when app goes in background. As documented:
So, if snapshot is removed then it will directly show the new pushed view controller.
(not sure about apple guideline for snapshot)
Update:
One approach can be:
Add a black colored background on the app screen when it goes in background(in
applicationDidEnterBackgroundmethod). So, it will show black screen while coming back to application.{ They store it for showing launch image for already started application.}Where it helps?
When we delete snapshots from ‘Preference’ directory of application sandbox(after application goes in background) and come back to application it shows black for a while as it does not have any snapshot.
The outcome of our approach and removing snapshot are same.