Iphone 打开应用程序时的APNS问题
当应用程序关闭(不在后台运行)且手机收到APNS时,Iphone 打开应用程序时的APNS问题,iphone,objective-c,apple-push-notifications,Iphone,Objective C,Apple Push Notifications,当应用程序关闭(不在后台运行)且手机收到APNS时,didReceiveRemoteNotification不会被调用 如果应用程序未在手机后台运行,则会收到APNS消息,单击横幅或弹出通知会打开应用程序,但不会调用didReceiveMemoteNotification委托 谢谢。只有在您使用应用程序时(应用程序运行时)才会调用DidReceivereMotentification,如果您想在用户单击横幅通知时执行某些特定操作,则在Appdelegate的-(BOOL)中调用应用程序:应用程序
didReceiveRemoteNotification
不会被调用
如果应用程序未在手机后台运行,则会收到APNS消息,单击横幅或弹出通知会打开应用程序,但不会调用didReceiveMemoteNotification
委托
谢谢。只有在您使用应用程序时(应用程序运行时)才会调用DidReceivereMotentification,如果您想在用户单击横幅通知时执行某些特定操作,则在Appdelegate的-(BOOL)中调用应用程序:应用程序使用选项完成启动:启动选项检查是否通过通知发送
// Handle notification when app is quit
NSDictionary *notification = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
if (notification != nil) {
[self handleNotificationsForApplication:application notification:notification];
}
并推动方法处理申请通知:申请通知:通知
- (void)handleNotificationsForApplication:(UIApplication *)application notification:(NSDictionary *)userInfo {
NSDictionary *data = [[userInfo objectForKey:@"aps"] objectForKey:@"data"];
NSString *type = [data objectForKey:@"type"];
if ([type isEqualToString:@"app_update"]) {
// Show alert to do the update
}
else if ([type isEqualToString:@"new_chat"]) {
imageData = data;
if (application.applicationState != UIApplicationStateActive) {
// Open chat view
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:APP_NAME
message:[[userInfo valueForKey:@"aps"] valueForKey:@"alert"]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert setTag:2];
[alert show];
}
}
}