Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didReceiveRemoteNotification not being called when I tap on app icon after receiving a push notification while on background

When my app is on background and I receive a remote notification, two things can happen:

  1. I tap on the push notification banner, my apps comes to foreground and didReceiveRemoteNotification is called.

  2. 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?

like image 406
Mario Frade Avatar asked Feb 14 '14 10:02

Mario Frade


People also ask

How do I turn on push notifications on settings?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.

Where does a push notification appear?

The definition of push notification They can appear on a lock screen or in the top section of a mobile device. An app publisher can only send a push notification if the user has their app installed. If you have installed the app and have enabled push notifications, they can be sent by the app publisher at any time.

How do I enable push notifications for apps on Iphone?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered—immediately or in the scheduled notification summary.


1 Answers

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
like image 176
frankWhite Avatar answered Oct 05 '22 06:10

frankWhite