当我的应用程序在后台运行并且我收到远程通知时,可能会发生两件事:
我点击推送通知横幅,我的应用程序进入前台并调用 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)