推送需要开启
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
NSMutableSet *categories = [NSMutableSet set];
UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];
category.identifier = @"identifier";
UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init];
action.identifier = @"cancel";
action.title = @"cancel";
action.activationMode = UIUserNotificationActivationModeBackground;
action.authenticationRequired = YES;
//YES显示为红色,NO显示为蓝色
action.destructive = NO;
NSArray *actions = @[ action ];
[category setActions:actions forContext:UIUserNotificationActionContextMinimal];
[categories addObject:category];
//IOS8
// 创建UIUserNotificationSettings,并设置消息的显示类类型
UIUserNotificationSettings *notiSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIRemoteNotificationTypeSound) categories:categories];
[application registerUserNotificationSettings:notiSettings];;
} else{ // ios7
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)];
}