iOS8推送消息的回复处理速度
iOS8我们有一个新的通知中心,我们有一个新的通报机制。当在屏幕的顶部仅需要接收一个推拉向下,你可以看到高速接口,天赋并不需要输入应用程序的操作。锁定屏幕,用于高速处理可以推动项目。
推送信息,再次提高处理效率。
可以进行直接互动的短信、邮件、日历、提醒,第三方应用,可以让你不用进入程序就能进行快捷操作,并专注于手中正在做的事情。
- 在通知横幅高速回复信息,不用进入短信程序;
- 可直接拒绝或接受邮件邀请;
- 可对提醒进行标记为完毕或推迟;
- 当第三方应用更新接口后便可直接相应用进行高速操作。
近期研究了下iOS8的官方文档。对这项功能进行了钻研,基本上效果已经出来。由于远程消息推送比較繁琐,须要后台支持,所以我用本地推送来取代的,基本上它们要调用的代理方法类似。
长话短说,以下我就说下主要的流程:
1.创建消息上面要加入的动作(button的形式显示出来)
UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init];
action.identifier = @"action";//button的标示
action.title=@"Accept";//button的标题
action.activationMode = UIUserNotificationActivationModeForeground;//当点击的时候启动程序
// action.authenticationRequired = YES;
// action.destructive = YES; UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init]; //第二button
action2.identifier = @"action2";
action2.title=@"Reject";
action2.activationMode = UIUserNotificationActivationModeBackground;//当点击的时候不启动程序。在后台处理
action.authenticationRequired = YES;//须要解锁才干处理,假设action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;
action.destructive = YES;
2.创建动作(button)的类别集合
UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];
categorys.identifier = @"alert";//这组动作的唯一标示
[categorys setActions:@[action,action2] forContext:(UIUserNotificationActionContextMinimal)];
3.创建UIUserNotificationSettings,并设置消息的显示类类型
UIUserNotificationSettings *uns = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound) categories:[NSSet setWithObjects:categorys, nil]];
4.注冊推送
[[UIApplication sharedApplication] registerUserNotificationSettings:uns];
<pre name="code" class="objc">[[UIApplication sharedApplication] registerForRemoteNotifications];
UserRequires call to registerUserNotificationSettings:• SilentInfo.plist UIBackgroundModes array contains remote-notification• Can use both
离线push数据包带上特定Category字段(字段内容需要前后台一起定义。必需要保持一致),手机端收到时。就能展示上述代码相应Category设置的button,和响应button事件。
// payload example: {"aps":{"alert":"Incoming call", "sound":"default", "badge": 1, "category":"incomingCall"}}
重大改动: 离线push数据包之前能带的数据最多为256字节,如今APPLE将该数值放大到2KB。
这个应该是仅仅针对IOS8的。
5.发起本地推送消息
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:5];
notification.timeZone=[NSTimeZone defaultTimeZone];
notification.alertBody=@"測试推送的快捷回复";
notification.category = @"alert";
[[UIApplication sharedApplication] scheduleLocalNotification:notification]; //用这两个方法推断是否注冊成功
// NSLog(@"currentUserNotificationSettings = %@",[[UIApplication sharedApplication] currentUserNotificationSettings]);
//[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
6.在AppDelegate.m里面对结果进行处理
//本地推送通知
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//成功注冊registerUserNotificationSettings:后,回调的方法
NSLog(@"%@",notificationSettings);
} -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
//收到本地推送消息后调用的方法
NSLog(@"%@",notification);
} -(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler
{
//在非本App界面时收到本地消息,下拉消息会有快捷回复的button,点击button后调用的方法,依据identifier来推断点击的哪个button,notification为消息内容
NSLog(@"%@----%@",identifier,notification);
completionHandler();//处理完消息。最后一定要调用这个代码块
} //远程推送通知
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
//向APNS注冊成功,收到返回的deviceToken
} -(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
//向APNS注冊失败,返回错误信息error
} -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
//收到远程推送通知消息
} -(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler
{
//在没有启动本App时。收到server推送消息。下拉消息会有快捷回复的button,点击button后调用的方法,依据identifier来推断点击的哪个button
}
执行之后要按shift + command +H,让程序推到后台,或者按command+L让模拟器锁屏,才会看到效果。
假设是程序退到后台了,收到消息后下拉消息,则会出现刚才加入的两个button;假设是锁屏了,则出现消息后,左划就会出现刚才加入的两个button。
效果例如以下:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveXVqaWFueGlhbmc2NjY=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
如今仅仅是能让消息中显示出button的形式,带输入框的还在研究中,假设大研究了,也谢谢分享什么啊。我们共同努力改善!
代码:https://github.com/ios44first/PushDemo
(转载请注明地址。谢谢 http://blog.csdn.net/yujianxiang666/article/details/35260135)
iOS8推送消息的回复处理速度的更多相关文章
- iOS8推送消息的快速回复处理
http://blog.csdn.net/yujianxiang666/article/details/35260135 iOS8拥有了全新的通知中心,有全新的通知机制.当屏幕顶部收到推送时只需要往下 ...
- IOS中程序如何进行推送消息(本地推送,远程推送)
[1]-------------什么是推送消息? 我就以一张图解释------------ [2]-----------IOS程序中如何进行本地推送?----------- 2.1,先征求用户同意 1 ...
- IOS 本地通知推送消息
在现在的移动设备中,好多应用性的APP都用到了推送服务,但是有好多推送的内容,比如有的只是单纯的进行推送一个闹钟类型的,起了提醒作 用,有的则是推送的实质性的内容,这就分为推送的内容来区别用什么推送, ...
- 点击推送消息跳转处理(iOS)
当用户点击收到的推送消息时候,我希望打开APP,并且跳转到对应的界面,这就需要在AppDelegate里面对代理方法进行处理. 当用户点击推送消息打开APP的时候会调用 - (BOOL)applica ...
- iOS 远程推送消息解析及逻辑处理
关于远程推送的相关配置网上已经有足够多的教程,这里就不复述了.这里讲述当客户端收到推送消息后,应怎样对其进行相应的逻辑处理. 工程的AppDelegate.m文件里提供了如下方法: //当应用程序启动 ...
- iOS监听模式系列之推送消息通知
推送通知 和本地通知不同,推送通知是由应用服务提供商发起的,通过苹果的APNs(Apple Push Notification Server)发送到应用客户端.下面是苹果官方关于推送通知的过程示意图: ...
- 微信硬件平台(八) 4 ESP8266通过微信公众号给用户推送消息
https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=自己申请微信公众号的TOKEN 输出结果: 由于aRDUINO串 ...
- 极光推送消息——Alias别称方式(Andirod)
1.pom文件引入相关jar包 <!--极光推送消息start--> <dependency> <groupId>net.sf.json-lib</group ...
- 使用PushSharp给iOS应用推送消息
PushSharp是一个C#编写的服务端类库,用于推送消息到各种客户端,支持iOS(iPhone/iPad).Android.Windows Phone.Windows 8.Amazo.Blackbe ...
随机推荐
- [Windows Phone]AnimationHelper管理分散的Storyboard
问题描述: 在Windows Phone开发时候,可能存在这样的问题: 某一个控件需要一个特定的展现(这里假定是一个特定动画),那么我们会这么解决这个问题呢? 打开Blend,根据需求需求给控件添加动 ...
- 常用的JQuery数字类型验证正则表达式
var regexEnum = { intege:"^-?[1-9]//d*$", //整数 intege1:"^[1-9]//d*$", ...
- dsp下基于双循环缓冲队列的视频采集和显示记录
对最近在设计的视频采集和显示缓冲机制做一个记录,以便以后使用. 视频采集和显示缓冲机制,其实是参考了Linux下v4L2的驱动机制,其采用输入多缓冲frame,输出多缓冲的切换机制.简单的就是ping ...
- 18.如何自我Struts2它Struts2标签和综合汇总文章有点早
18.如何自我Struts2它Struts2标签和综合汇总文章有点早[视频] 之前写了一篇"打算做一个视频教程探讨怎样自学计算机相关的技术",优酷上传不了.仅仅好传到百度云上: h ...
- DIV固定在页面某个位置,不随鼠标滚动而滚动
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org ...
- fs学习笔记之输出格式
接触fs那么久,有必要再记录一下. 上一篇介绍了fs拓扑描写叙述文件dot的格式,今天要介绍fs输出文件的格式. 举个样例,下面是d节点输出文件的一行记录,也就是一条流经过d的记录. textexpo ...
- Struts2中指定的校验文件不起作用的原因
转载请注意出处:http://blog.csdn.net/bettarwang/article/details/39801733 我们知道,假设要为某个Action指定校验文件.那么就要将" ...
- HDU 3277 Marriage Match III(二分+最大流)
HDU 3277 Marriage Match III 题目链接 题意:n个女孩n个男孩,每一个女孩能够和一些男孩配对,此外还能够和k个随意的男孩配对.然后有些女孩是朋友,满足这个朋友圈里面的人.假设 ...
- hdu2712(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2712 题意:是求最短的非子串(子串不要求连续)的长度. 分析:把序列划分为尽量多(假设为ans)的含有 ...
- Phalcon之 表单(Forms)
Phalcon中提供了 Phalcon\Forms组件以方便开发人员创建和维护应用中的表单. 以下的样例中展示了主要的用法: <?php use Phalcon\Forms\Form, Phal ...