在后台收到推送通知后点击应用程序图标时,不会调用 didReceiveRemoteNotification [英] didReceiveRemoteNotification not being called when I tap on app icon after receiving a push notification while on background

查看:44
本文介绍了在后台收到推送通知后点击应用程序图标时,不会调用 didReceiveRemoteNotification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

I tap on my app icon from the springboard, my app comes to foreground and didReceiveRemoteNotification IS NOT called.

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

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.

如何使用 Quickblox 解决此问题?

How can I solve this using Quickblox?

推荐答案

作为一种可能的变体:

@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

这篇关于在后台收到推送通知后点击应用程序图标时,不会调用 didReceiveRemoteNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆