Reputation: 3221
When the iPhone application is running in background and it receive a remote notification. So it will execute the didReceiveRemoteNotification
call back. In that I am going to push to a new UIViewController
. But before that its noticed that its calling the applicationWillEnterForeground
callback.
In that I am also doing some location update using a modal dialog. So when this notification arrives this both scenarios happens and the app is getting crashed. So is there any way to block the applictiaonWillEnterBackground
processing on remote notification. As the moment is little bit hard cos this processing is done after applicationWillEnterBackground
controller.
Thank you.
Upvotes: 0
Views: 5308
Reputation: 10080
The callback application:didReceiveRemoteNotification:
should only be invoked when the application is running in the foreground. When running in the background you should instead get a call to application:didFinishLaunchingWithOptions:
.
Since you are asking the question and also using core location it might be that application:didReceiveRemoteNotification:
is called when the application is in the background but I would think that would be a bug. At least according to Apple's documentation.
Anyway, NO, you can't block applicationWillEnterForeground:
. Without knowing exactly what you are doing in the different callbacks I would recommend that you set a flag in applicationWillEnterForeground:
if you are doing something there and then check that flag in application:didReceiveRemoteNotification:
- (void)applicationWillEnterForeground:(UIApplication *)application {
if (somehingHappend) {
somethingHappended = YES;
}
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (!somethingHappened) {
// push your view controllers or whatever
}
}
Where somethingHappened
is a BOOL
defined in the same class as an ivar.
Upvotes: 3