iOS and PushKit

This post will cover basic concepts for VoIP apps on iOS.

I will not post any code (Google it out if necessary). I will compare two ways of developing VoIP on iOS and write down my notes while developing them.

VoIP apps before iOS 8

Before iOS 8, VoIP apps had to maintain persistent background connection (VoIP socket) with the server. When a new incoming call arrived iOS gave some execution time to the app so it could notify user (via local notifications).

Developers could add remote push notifications to inform users about incoming calls but apps did not receive any execution time there. Remote push notifications are not reliable since users can disable them at anytime.

To be available as much as possible apps had to perform the following steps:
1.) Configure one of the app’s sockets for VoIP usage
2.) Before moving to the background set a keepAlive timeout handler to be executed periodically
3.) Observing network changes

When keepAlive timeout expired (minimum 10 min) or when network configuration changed, app received a few sec (< 10) of execution time to maintain VoIP socket with the server.

This way of working had two major down sides. It was a drain on the battery and if the app was closed by the user (or crashed) all VoIP calls would have been missed, until the app was executed by the user.

VoIP apps with PushKit (iOS 8+)

With iOS 8 there is a new, more energy efficient way to create iOS VoIP apps - VoIP Push notifications.

VoIP notifications have higher priority compared to regular push notifications and they give you some execution time when received.

They are more reliable (more about this in notes :)) and a lot more useful.  Received VoIP push notification will wake up or launch your app (almost) anytime, regardless if your app crashed, was terminated by user, or device was restarted.

You no longer have to maintain persistent connections with your server, set timeouts or observe network changes.

Your VoIP app must do two things on startup:
1.) Initialize PushKit (VoIP type) and set its delegate. User does not need to allow it and cannot disable it
2.) Register for posting user notifications about incoming calls (user confirmation is required)

There is no need for any active connection to the server when there is no active call. When incoming call is created, server will send VoIP push notification to your device.

This notification will wake your app and give you some time to connect to the server (if needed) and notify user about the call.  When a call ends you can disconnect from the server.

Battery drain is minimal since your app doesn’t need to run in the background. User can kill your app and still be reachable.

Sample code with PushKit integration can be found in here.

My notes regarding PushKit

Not receiving notifications after device reboot: 
- Before initializing PushKit start a background task. Finish this task when PushKit token is received.

Not receiving pushes after app crashed:
- This happens only if your app crashes while processing push notifications. Make sure you do not have a bug in your PushKit delegate function.

Not receiving pushes after app is few hours in background:
- This is a bug in iOS and it it occurs after few days, sometimes after few hours. When your app gets to this point, it has to be launched manually. We have reported this bug to Apple. If you are facing same issue, you can follow this thread on Apple Dev forum: https://devforums.apple.com/message/1113824

Written by: Miha Majcen

特别感谢本文原作者的分享:http://blog.biokoda.com/post/114315188985/ios-and-pushkit 

PushKit和传统长连接方式的比较的更多相关文章

  1. jsp实时显示后台批处理进度 - out分块,简单的长连接方式

    这两天在实现一个批处理操作,但是想让前台实时显示后台批处理进度,本想着用复杂一些的框架可以实现异步信息调用 但是鉴于是内部管理系统,且只有一两个人用到这个功能,所以做了一个简单的长连接方式的实时响应 ...

  2. IM推送保障及网络优化详解(二):如何做长连接加推送组合方案

    对于移动APP来说,IM功能正变得越来越重要,它能够创建起人与人之间的连接.社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性. 在复杂的 Android 生态环境下,多种因素都会造成消息推送 ...

  3. Loadrunner_http长连接设置

    最近协助同事解决了几个问题,也对loadrunner的一些设置加深了理解,关键是更加知其所以然. ljonathan http://www.51testing.com/html/48/202848-2 ...

  4. Qt 5 最新信号和槽连接方式以及Lambda表达式

    最近学习Qt,发现新大陆,这里做下记录. 主要内容就是原始Qt4的信号槽连接方式,以及Qt5新版的连接方式,还有件事简单演示一下lambda表达式的使用方式 代码如下 /* * 作者:张建伟 * 时间 ...

  5. NIO单一长连接——dubbo通信模型实现

    转: NIO单一长连接——dubbo通信模型实现 峡客 1.2 2018.07.15 19:04* 字数 2552 阅读 6001评论 30喜欢 17 前言 前一段时间看了下dubbo,原想将dubb ...

  6. HTTP长连接(Comet)实现方式示例

    昨天看了comet的介绍后,虽然大概知道了comet的原理,不过没实际用过还是不太清楚,于是今天又在网上翻了一下别的网友共享的comet实现http长连接的例子,在 Comet Server Push ...

  7. SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论 SignalR 简单示例 通过三个DEMO学会SignalR的三种实现方式 SignalR推送框架两个项目永久连接通讯使用 SignalR 集线器简单实例2 用SignalR创建实时永久长连接异步网络应用程序

    SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论   异常汇总:http://www ...

  8. Android实现推送方式解决方案 - 长连接+心跳机制(MQTT协议)

    本文介绍在Android中实现推送方式的基础知识及相关解决方案.推送功能在手机开发中应用的场景是越来起来了,不说别的,就我们手机上的新闻客户端就时不j时的推送过来新的消息,很方便的阅读最新的新闻信息. ...

  9. php和mysql连接方式(短 长 池)

    一个php work进程只能处理一个请求,当完成一个请求了,才能处理下一次的请求 2.短连接: 执行到php关闭mysql连接的代码时,就断开,否则在处理本次请求结束的时候,释放mysql连接 实验: ...

随机推荐

  1. 【python游戏编程之旅】第三篇---pygame事件与设备轮询

    本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 在上一篇博客中,我们学习了pygame中的IO.数据http://www.cnblogs.com/msxh/ ...

  2. BZOJ3755 : Pty爬山

    l[i],r[i]表示站在i点往左往右走能看到的最高峰,用栈维护凸壳求出 h[i]表示i点能看到的最高峰的高度 a[i],b[i]表示i点往左往右走时反悔的点,即第一个h[j]>h[i]的j,用 ...

  3. pygame系列_百度随心听_完美的UI设计

    这个程序的灵感来自于百度随心听 下面是我的程序截图: 说明: 动作按钮全部是画出来的,没有用到任何图片 用到图片的只有:背景,歌手图片,作者图片 代码正在调试中.... 如果你鼠标移动到黄色小圆里面, ...

  4. oracle系列--第一篇 数据库基础

    第一章 数据库基础 1.1 数据管理概述 1.1.1 什么是数据管理 与我们人类相比,计算机的最大优势就是能够高速.精准地运行,其运行的过程就是执行程序代码和操作指令.处理数据的过程.可以说,数据处理 ...

  5. c++ vector 的使用

    vector(向量): C++中的一种数据结构,确切的说是一个类.它相当于一个动态的数组,当程序员无法知道自己需要的数组的规模多大时,用其来解决问题可以达到最大节约空间的目的. 用法: 1. 首先在程 ...

  6. 【C语言】08-数组

    为了让大家更好地学习和理解数组,我们先来认识一下内存中的"地址". 地址 1.计算机中的内存是以字节为单位的存储空间.内存的每一个字节都有一个唯一的编号,这个编号就称为地址.凡存放 ...

  7. 应用服务器上部署自己的 blog 和 wiki 组件。

    协作性应用程序 这就是 Web 2.0 的全部,尽管该术语出现才几乎一年的时间,但现在好像只有烹饪杂志还没有加入到讨论 Web 2.0 未来出路的行列中.自从出现了里程碑式的文章 "What ...

  8. [转]Entity Framework走马观花之把握全局

    本文转自:http://blog.csdn.net/bitfan/article/details/12887007 Entity Framework走马观花 之 把握全局 ============== ...

  9. 安装Bind过程中提示丢失MSVCR110.dll的解决办法

    前几天在线安装Visual Studio 2012 Update 3,由于在线安装需要不断下载安装文件,时间很长,后来等不下去,就取消了,不幸的是VS启动不了了,弹出“devenv.exe – 系统错 ...

  10. 如何删除 OpenStack Nova 僵尸实例

    转自:http://www.vpsee.com/2011/11/how-to-delete-a-openstack-nova-zombie-instance/ 前天强制重启一台 OpenStack N ...