xcode – iOS8中无法打开应用程序的可操作通知

前端之家收集整理的这篇文章主要介绍了xcode – iOS8中无法打开应用程序的可操作通知前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
实际上我正在进行可操作的通知.一切正常我正在获得按钮触发动作,但问题是当我点击按钮时应用程序没有打开.当我手动打开应用程序时触发相应的操作并转到确切的屏幕,但是当我点击按钮时它不会发生.

这是我可操作通知的设置

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相关文章