didReceiveRemoteNotification not being called when I tap on app icon after receiving a push notification while on background
chat, ios, objective-c, push-notification, quickblox
Solution
As one possible variant:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (userInfo) {
[self handleRemoteNotifications:userInfo];
}
// Override point for customization after application launch.
return YES;
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[self handleRemoteNotifications:userInfo];
}
#pragma mark - Remote notifications handling
-(void)handleRemoteNotifications:(NSDictionary *)userInfo {
// do your stuff
}
@end
Problem
When my app is on background and I receive a remote notification, two things can happen: I tap on the push notification banner, my apps comes to foreground and didReceiveRemoteNotification is called. I tap on my app icon from the springboard, my app comes to foreground and didReceiveRemoteNotification IS NOT called. So, in the scenario 1, I can update my counter of unread messages inside the app in response to didReceiveRemoteNotification. In the scenario 2, I can't. How can I solve this using Quickblox?