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. DDD, MVC & Entity Framework

    https://digitalpolis.co.uk/software-thoughts/ddd-mvc-entity-framework/ Data Points - Coding for Doma ...

  2. Python合并两个numpy矩阵

    numpy是Python用来科学计算的一个非常重要的库,numpy主要用来处理一些矩阵对象,可以说numpy让Python有了Matlab的味道. 实际的应用中,矩阵的合并是一个经常发生的操作,如何利 ...

  3. jQuery.form.js使用

    jQuery.form.js是一个form插件,支持ajax表单提交和ajax文件上传. 下载地址 百度云:http://pan.baidu.com/s/1eQoYE46 360云:http://yu ...

  4. Linux-HAproxy+Keepalived

    HAproxy+++++++++++++Info+++++++++++VIP:192.168.1.222HA-Master IP:192.168.1.117HA-Backup IP:192.168.1 ...

  5. generator函数

    function* helloWordGenerator() { yield "hello"; yield "world"; return "endi ...

  6. Amoeba:开源的分布式数据库Porxy解决方案

    http://www.biaodianfu.com/amoeba.html 什么是Amoeba? Amoeba(变形虫)项目,该开源框架于2008年 开始发布一款 Amoeba for Mysql软件 ...

  7. java 框架Nutz

    http://nutzam.com/ Nutz 可以做什么? Dao -- 针对 JDBC 的薄封装,事务模板,无缓存 Ioc -- JSON 风格的配置文件,声明时切片支持 Mvc -- 注解风格的 ...

  8. nginx+tomcat+redis的集群+session共享

    nginx+tomcat+redis的集群+session共享 环境准备 1.tomcat版本:tomcat7 tomcat下载及安装,目前很多好的资源和步骤,此处省略. 2.jdk版本:jdk1.7 ...

  9. json字符串转map

    <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</ar ...

  10. struts checkbox选中

    <input type="checkbox" id="something" name="something" /> ↓ < ...