当我在后台收到推送通知后点击应用程序图标时,没有调用didReceiveRemoteNotification [英] 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:
-
我点击了推送通知横幅,我的应用程序到达前台并且调用了didReceiveRemoteNotification。
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屋!