iOS VoIP push and PushKit

来源:互联网 发布:网络教育大专报名 编辑:程序博客网 时间:2024/06/06 20:13

What PushKit does and why you should use it.

In iOS 8 Apple introduced PushKit as part of their effort to improve battery life, performance, and stability for VoIP applications such as Skype, WhatsApp, and LINE.

Previously, VoIP apps needed to maintain a persistent connection in order to receive calls. Keeping a connection open in the background, drains the battery as well as causes all kinds of problems when the app crashes or is terminated by the user.

PushKit is meant to solve these problems by offering a high-priorty push notification with a large payload. The VoIP app receives the notification in the background, sets up the connection and displays a local notification to the user. When the user swipes the notification, the call is ready to connect.

Question:pushkit是什么?

Answer:ios8苹果新引入了名为pushkit的框架和一种新的push通知类型,被称作voip push.该push方式旨在提供区别于普通apns push的能力,通过这种push方式可以使app执行制定的代码(在弹出通知给用户之前);而该通知的默认行为和apns通知有所区别,它的默认行为里面是不会弹出通知的。目前来看push kit的用途还局限于voip push(根据笔者的实战经验来看,其他类型的push暂时不能够起作用,sdk也正处于演进中)。

Question: pushkit能帮我们做什么?

Answer:pushkit中的voippush,可以帮助我们提升voip应用的体验,优化voip应用的开发实现,降低voip应用的电量消耗,它需要我们重新规划和设计我们的voip应用,从而得到更好的体验(voip push可以说是准实时的,实侧延时1秒左右);苹果的目的是提供这样一种能力,可以让我们抛弃后台长连接的方案,也就是说应用程序通常不用维持和voip服务器的连接,在呼叫或者收到呼叫时,完成voip服务器的注册;当程序被杀死或者手机重启动时,都可以收到对方的来电,正常开展voip的业务。也就是说,我们当前可以利用它来优化voip的体验,增加接通率;条件成熟时我们就可以完全放弃后台的长连接,走到苹果为我们规划的道路上。

对于pushkit,除了苹果framework官方文档:https://developer.apple.com/library/prerelease/ios/documentation/NetworkingInternet/Reference/PushKit_Framework/index.html#protocols 以外,能够找到的帮助理解pushkit的莫过于wwdc的视频:712_sd_writing_energy_efficient_code_part_2。该视频也可以从苹果官网下载。

pushkit的局限:

在当前,pushkit仅支持ios8;且该功能正处于演进中,稳定性和在不同ios8小版本设备上的表现也可能有差异,在苹果开发者论坛上也有不少人反馈问题;根据经验,在下个大版本(也就是ios9)上可以期待该功能可以稳定下来。

如果需要在ios8之前的设备上支持pushkit功能,那么需要开发者付出很多额外的努力,这里不展开,有兴趣的同学可以到苹果论坛的相关板块去了解,有一些开发者在这方面走的比较远:

在下面的链接中搜索pushkit关键字,可以查找到相关内容:

https://devforums.apple.com/community/ios/connected/push

https://zeropush.com/guide/guide-to-pushkit-and-voip

To test VoIP push on your own device, check out the demo project:https://github.com/ZeroPush/VoIP-Demo


0 0