gpt4 book ai didi

xcode - iOS8 中的可操作通知未打开应用程序

转载 作者:行者123 更新时间:2023-12-04 23:49:13 24 4
gpt4 key购买 nike

实际上,我正在处理可操作的通知。一切正常,我得到按钮触发 Action ,但问题是当我点击按钮时,应用程序没有打开。当我手动打开应用程序时,它会触发相应的操作并转到确切的屏幕,但是当我点击按钮时它不会发生。

这是我的可操作通知的设置

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];

这是在按下按钮后触发应用程序启动的原因。

关于xcode - iOS8 中的可操作通知未打开应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26798207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com