if (isiOS8)

{

//ios8的远程推送注册

NSSet *set = nil;

#if 1

//1.创建消息上面要添加的动作(按钮的形式显示出来)

UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init];

action.identifier = @"action";//按钮的标示

action.title=@"Accept";//按钮的标题

action.activationMode = UIUserNotificationActivationModeForeground;//当点击的时候启动程序

//    action.authenticationRequired = YES;

//    action.destructive = YES;

UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];  //第二按钮

action2.identifier = @"action2";

action2.title=@"Reject";

action2.activationMode = UIUserNotificationActivationModeBackground;//当点击的时候不启动程序,在后台处理

action.authenticationRequired = YES;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;

action.destructive = YES;

//2.创建动作(按钮)的类别集合

UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];

category.identifier = @"alert";//这组动作的唯一标示

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

//

set = [NSSet setWithObjects:category, nil];

//远程通知测试 消息体:  {"aps":{"alert":"Incoming call", "sound":"default", "badge": 1, "category":"alert"}}

//"category":"alert"必须对应 category.identifier = @"alert";

//本地通知测试

UILocalNotification *notification = [[UILocalNotification alloc] init];

notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:15];

notification.timeZone=[NSTimeZone defaultTimeZone];

notification.alertBody=@"测试推送的快捷回复";

notification.category = @"alert";

[[UIApplication sharedApplication]  scheduleLocalNotification:notification];

#endif

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)  categories:set]];

[[UIApplication sharedApplication] registerForRemoteNotifications];

}else

{

  //ios8以前的远程推送注册

UIRemoteNotificationType apn_type = (UIRemoteNotificationType)(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge);

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:apn_type];

}

}

-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler

{

//在没有启动本App时,收到服务器推送消息,下拉消息会有快捷回复的按钮,点击按钮后调用的方法,根据identifier来判断点击的哪个按钮

}

-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler

{

//在非本App界面时收到本地消息,下拉消息会有快捷回复的按钮,点击按钮后调用的方法,根据identifier来判断点击的哪个按钮,notification为消息内容

NSLog(@"%@----%@",identifier,notification);

completionHandler();//处理完消息,最后一定要调用这个代码块

}

ios8消息快捷处理——暂无输入框的更多相关文章

  1. Repeater为空时显示“暂无数据”,很方便实用方法

    Repeater为空时显示“暂无数据”,很方便实用方法 <FooterTemplate>   <asp:Label ID="lblEmptyZP" Text=&q ...

  2. Python之路【第十四篇】:AngularJS --暂无内容-待更新

    Python之路[第十四篇]:AngularJS --暂无内容-待更新

  3. Python之路【第十三篇】:jQuery -暂无内容-待更新

    Python之路[第十三篇]:jQuery -暂无内容-待更新

  4. Python之路【第十二篇】:JavaScrpt -暂无内容-待更新

    Python之路[第十二篇]:JavaScrpt -暂无内容-待更新

  5. Python之路【第十一篇】:CSS --暂无内容-待更新

    Python之路[第十一篇]:CSS --暂无内容-待更新

  6. Python之路【第十篇】:HTML -暂无等待更新

    Python之路[第十篇]:HTML -暂无等待更新

  7. 关于echart没有数据显示暂无数据

    对于echart当没有数据的时候怎么显示, 首先,如果你的series的值为空值的话,曲线将是一片空白,什么都不会有,所以在这里就要进行一个判断,如果没有值的话,人为的添加一个键 if(Object. ...

  8. easyUI datagrid表格添加“暂无记录”显示

    扩展grid的onAfterRender事件 var myview = $.extend({}, $.fn.datagrid.defaults.view, {     onAfterRender: f ...

  9. 帝国cms 此栏目暂无任何新增信息处理办法

    在做一个新网站的时候不能保证每个栏目都能填充内容,当某个栏目没有内容填充的时候总会出现“此栏目暂无任何新增信息”看着挺不舒服. 其实想删除这行字也挺简单,只需要修改下语言包即可!如下: 找到语言包文件 ...

随机推荐

  1. 拉动滚动条追加内容,无限延伸document高度 $(window).scroll(function(){if($(window).scrollTop() + $(window).height() == $(document).height()) { $("body").append(html) } })

    $(document).ready(function() { // endless scrolling $(window).scroll(function() { if($(window).scrol ...

  2. Sklearn库例子4:分类——Lasso分类例子

    Lasso回归: #-*- encoding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt from sklearn.met ...

  3. 一个关于正整数x的约数个数的结论

    分析理解:x的每一个约数都是由x的若干个质因数的积构成. 再根据乘法原理,每个质因数Pi的选择可以是0~Ni个,所以上述结论成立.

  4. CentOS6.4系统启动失败故障排查

    转:http://www.centoscn.com/CentosBug/osbug/2014/1028/4011.html 操作系统启动失败如下图报错: 故障现象: 从图中可以看到,操作系统启动的过程 ...

  5. MySQL和MongoDB语句的写法对照

    查询: MySQL: SELECT * FROM user Mongo: db.user.find() MySQL: SELECT * FROM user WHERE name = ’starlee’ ...

  6. js跳转到页面中指定的hash

    location.hash = "#filter_moreClue";

  7. 转载:使用sklearn做单机特征工程

    目录 1 特征工程是什么?2 数据预处理 2.1 无量纲化 2.1.1 标准化 2.1.2 区间缩放法 2.1.3 标准化与归一化的区别 2.2 对定量特征二值化 2.3 对定性特征哑编码 2.4 缺 ...

  8. [java]序列化框架性能对比(kryo、hessian、java、protostuff)

    序列化框架性能对比(kryo.hessian.java.protostuff) 简介:   优点 缺点 Kryo 速度快,序列化后体积小 跨语言支持较复杂 Hessian 默认支持跨语言 较慢 Pro ...

  9. css之伪类选择器:before :after(::before ::after)

    一.总结: ::before是在标签内容前面添加内容, ::after是在标签内容后面添加内容 ::before ::after与:before  :after的区别:css3中修订后的伪元素使用:: ...

  10. HackerRank "Minimum Average Waiting Time" !

    Something to learn: http://blog.csdn.net/yuwenshi/article/details/36666453 Shortest Job First Algori ...