您的位置:首页 > 其它

推送

2015-12-11 16:35 260 查看
推送需要开启

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: