当我在后台收到推送通知后点击应用程序图标时,没有调用didReceiveRemoteNotification

Mar*_*ade 11 chat objective-c push-notification ios quickblox

当我的应用程序在后台并收到远程通知时,可能会发生两件事:

  1. 我点击推送通知横幅,我的应用程序到达前台并调用didReceiveRemoteNotification.

  2. 我从跳板上点击我的应用程序图标,我的应用程序到达前台并且没有调用didReceiveRemoteNotification.

因此,在方案1中,我可以更新应用程序内部未读消息的计数器以响应didReceiveRemoteNotification.在方案2中,我不能.

如何使用Quickblox解决这个问题?

fra*_*ite 3

作为一种可能的变体:

@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
Run Code Online (Sandbox Code Playgroud)