ios8推送新增

ios8新增了catory字段 这个字段的标示符identifier必须和后台字段一致。

catory是

UIMutableUserNotificationCategory这个类 初始化的方法如下

    UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategoryalloc] init];

    categorys.identifier = @"categoryIdentifier";

    [categorys setActions:@[action,action2]forContext:(UIUserNotificationActionContextMinimal)];

相当于创建了一个按钮集合

代码中的action 即UIMutableUserNotificationAction

UIMutableUserNotificationAction *action = [[UIMutableUserNotificationActionalloc] init];

    action.identifier = @"action";

    action.title=@"Accept";

    action.activationMode = UIUserNotificationActivationModeForeground;


activationMode查看可知是一个结构体 

/*

 

typedef NS_ENUM(NSUInteger, UIUserNotificationActivationMode) {

 

    UIUserNotificationActivationModeForeground, // activates the application in the foreground

 

    UIUserNotificationActivationModeBackground  // activates the application in the background, unless it's already in the foreground

 

} NS_ENUM_AVAILABLE_IOS(8_0);

*/


注册通知

 

 [application registerForRemoteNotificationTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound) categories:[NSSetsetWithObjects:categorys, nil]];

这样就可以在通知栏里看到这样的效果了如下


IMG 0235


文章学习来源于 http://blog.csdn.net/apple_app/article/details/39228221

 

posted @ 2015-07-21 17:42  Mac-one  阅读(182)  评论(0编辑  收藏  举报