当我的应用程序在后台运行并且我收到远程通知时,可能会发生两件事:
我点击推送通知横幅,我的应用进入前台并调用 didReceiveRemoteNotification。
我从跳板上点击我的应用程序图标,我的应用程序进入前台并且未调用 didReceiveRemoteNotification。
因此,在场景 1 中,我可以更新应用程序内的未读消息计数器以响应 didReceiveRemoteNotification。 在方案 2 中,我不能。
如何使用 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
关于ios - 当我在后台收到推送通知后点击应用程序图标时,没有调用 didReceiveRemoteNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21776618/