Save battery life by backgrounding VoIP calls using CallKit in iOS
- Voice over Internet Protocol facilitate smartphone users to have audio and video calls over internet connection (Wifi / 3G / 4G).
- Nowadays, almost every communication app is enabled with this functionality.
- As VOIP apps are heavily relies on internet connection, it results in high battery usage which makes phone battery drains too fast.
What is CallKit?
- CallKit is a new framework which is available in iOS version 10 and later.
- It is specifically used to implement VoIP functionality, call blocking and identification in your app.
- Apps can use CallKit to receive incoming calls and outgoing calls using the native call UI.
What is PushKit?
- In past, VoIP app has to maintain a persistent connection to server for receiving incoming calls even when app is not in use (background mode). Apple has solved this common problem by introducing PushKit Framework.
- Now, instead of using persistent connection always, Apps can use PushKit framework to receive both normal and VoIP push notifications from server. This can save iPhone Battery life in a remarkable way.
How it works?
Preparing App to receive VOIP push:
1. Your app should have background mode enable for VoIP
2. You should have VoIP Service Certificate for your app
- Login with apple account > Open certificate tab > Create VOIP certificate
- Create csr file using keychain
Open Keychain > select Certificate Assistance > Request Certificate from a certificate authorityNow enter all detail like Email id ,Key name and select “save to disk” option.
- Now install VOIP cert on keychain.
To do so: Double click on VOIP.cert and install
- Now open Certificate tab of Keychain access,Search VOIP cert and export cert as .p12.
- Now make .pem file for Push Notification using following command:
openssl pkcs12 -in YOUR_CERT.p12 -out VOIP.pem -nodes -clcerts
- Test .pem file using Houston
apn push “<21091153 2f06f5fe 14fb627a 277e8459 7de3be4b e80d250e 793ccf29 341c31de>” -c /Users/inex_macmini_3/Documents/Documents//VOIP_app.pem -m “Testing PEM”
3. At last, You need to add CallKit and PushKit framework to your app.
And you are done.
We, at Inextrix providing iOS development services by our experienced developers.
Please visit http://inextrix.com/services/ios-application-development to know about iOS development services.