推送
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)];
}
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)];
}
相关文章推荐
- mount挂载
- thinkphp裁剪png图片背景不透明
- LeetCode 70:Climbing Stairs
- 从头认识java-13.4 泛型方法的使用
- Android知识总结:Universal-Imageloader学习笔记4 使用Universal-Imageloader管理本地图片
- http 请求406
- 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
- 长大了,意味着没有真话可讲
- MySQL安装与配置
- iOS socket 知识
- jsp页面日期处理
- grails防止表单重复提交
- iOS GCD 学习
- 做了个导出AssetBundle的小插件
- 网络字节序、主机字节序
- 分组找ID
- mybatis缓存机制
- iOS创建静态库
- C#之DirectoryInfo操作
- Tomcat(免安装版)的安装与配置