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

查看:161
本文介绍了当我在后台收到推送通知后点击应用程序图标时,没有调用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 IS没有被调用。

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

因此,在方案1中,我可以在应用程序内更新我的未读消息计数器to 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天全站免登陆