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. glibc下的内存管理

    在解码过程中我们也遇到了类似的问题,第一次解码的音频比较大60s,耗了3G的内存,reset之后内存并没有退还给操作系统,第二次即使解一个10s的音频 几周前我曾提到,我被项目组分配去做了一些探究li ...

  2. mysql学习之-密码管理(默认密码,修改密码,解决忘记密码)

    1. mysql安装后默认没有密码,初始化安装后默认密码登录,需要马上修改root密码.[root@mysql ~]# cat /root/.mysql_secret    --查看root账号密码# ...

  3. C++重载,重写,重定义

    1.重载:重载是在一个类中,函数名一样,参数类型或参数个数不同的一系列函数需要注意的是,与返回类型无关. class Test { public: void show(); void show(int ...

  4. JS之变量的运算

    js变量的特点: 1.区分大小写,这是与html及css最大的不同: 2.弱变量.通过var进行定义,无明确的数据类型. 第一部分 字符型 对于字符型的数据,常用的操作为字符的转换.字符的操作 1.字 ...

  5. debug,trace,release项目配置区别

    Debug模式是用来调试用的,它生成的执行文件中含有大量调试信息,所以很大: Release模式生成的执行文件消除了这些调试信息,可用来作为成品发布 Debug只在debug状态下会输出,Trace在 ...

  6. asp.net web api [FromBody]参数

    Using jQuery to POST [FromBody] parameters to Web API 时间2013-04-04 00:28:17 Encosia原文 http://encosia ...

  7. 【性能诊断】七、并发场景的性能分析(windbg案例,线程阻塞)

    简单整理一个测试Demo,抓取dump并验证,步骤如下: Symbol File Path:SRV*C:\Symbols*http://msdl.microsoft.com/download/symb ...

  8. 读书笔记:Ross:概率模型导论:方差和协方差

    例2.34 考虑N个人,一些人赞同某个提议,另一些人反对.假定Np个人赞同,N-Np人反对,p未知.现在想要通过随机选取n个人调查他们的态度,并由此来估计总体中赞同这个提议的人员比例p. 设Xi=1表 ...

  9. Env:Cscope安装与配置

    1. 介绍 Cscope是类似于ctags一样的工具,但可认为他是ctags的增强版. 2. 安装 sudo apt-get install cscope 通过源码安装,参照http://blog.c ...

  10. activiti自定义流程之整合(二):使用angular js整合ueditor创建表单

    注:整体环境搭建:activiti自定义流程之整合(一):整体环境配置 基础环境搭建完毕,接下来就该正式着手代码编写了,在说代码之前,我觉得有必要先说明一下activit自定义流程的操作. 抛开自定义 ...