xcode – iOS8中无法打开应用程序的可操作通知
发布时间:2020-12-14 17:43:11 所属栏目:百科 来源:网络整理
导读:实际上我正在进行可操作的通知.一切正常我正在获得按钮触发动作,但问题是当我点击按钮时应用程序没有打开.当我手动打开应用程序时触发相应的操作并转到确切的屏幕,但是当我点击按钮时它不会发生. 这是我可操作通知的设置 NSString * const NotificationCateg
实际上我正在进行可操作的通知.一切正常我正在获得按钮触发动作,但问题是当我点击按钮时应用程序没有打开.当我手动打开应用程序时触发相应的操作并转到确切的屏幕,但是当我点击按钮时它不会发生.
这是我可操作通知的设置 NSString * const NotificationCategoryIdent = @"ACTIONABLE"; NSString * const NotificationActionOneIdent = @"ACTION_ONE"; NSString * const NotificationActionTwoIdent = @"ACTION_TWO"; -(UIMutableUserNotificationCategory*)registerActions { UIMutableUserNotificationAction *action1; action1 = [[UIMutableUserNotificationAction alloc] init]; [action1 setActivationMode:UIUserNotificationActivationModeBackground]; [action1 setTitle:@"Open"]; [action1 setIdentifier:NotificationActionOneIdent]; [action1 setDestructive:NO]; [action1 setAuthenticationRequired:NO]; UIMutableUserNotificationAction *action2; action2 = [[UIMutableUserNotificationAction alloc] init]; [action2 setActivationMode:UIUserNotificationActivationModeBackground]; [action2 setTitle:@"Delete"]; [action2 setIdentifier:NotificationActionTwoIdent]; [action2 setDestructive:NO]; [action2 setAuthenticationRequired:NO]; UIMutableUserNotificationCategory *actionCategory; actionCategory = [[UIMutableUserNotificationCategory alloc] init]; [actionCategory setIdentifier:NotificationCategoryIdent]; [actionCategory setActions:@[action1,action2] forContext:UIUserNotificationActionContextDefault]; NSSet *categories = [NSSet setWithObject:actionCategory]; UIUserNotificationType types = (UIUserNotificationTypeAlert| UIUserNotificationTypeSound| UIUserNotificationTypeBadge); UIUserNotificationSettings *settings; settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; return actionCategory; } 什么可能是确切的问题?有人可以帮助我..提前谢谢. 解决方法[action1 setActivationMode:UIUserNotificationActivationModeBackground]; 应该: [action1 setActivationMode:UIUserNotificationActivationModeForeground]; 这是按下按钮后启动应用程序的原因. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |