VOIP-Push-Notification-With-Swift

VOIP Push Notification With Swift

Spread the love

A Voice over Internet Protocol (VoIP) is used to make and receive phone calls using an Internet connection instead of the device’s cellular service.

From iOS 8, VoIP apps need to maintain a persistent connection with the server to receive calls using Internet connection. 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.

With iOS 8 Apple introduced PushKit, it improved battery life, performance and stability of messaging apps. PushKit can solve these problems by offering a high-priority push notification with a large payload. The VoIP app lets users receive the VoIP push notification in the background, sets up the connection or process dat,a and displays a local notification to the user. When the user swipes the notification, the call/data is ready to connect/display.


Why do we need PushKit?

If you are making a VoIP application, then you definitely want to update your application in the background state as well as wake your application when any VoIP call is being received.

We cannot achieve this by using APNs because iOS Push Notification will not wake up the app when the application is in the terminated state.


There are a couple of benefits of PushKit-


1. PushKit notifications are never presented to the user (Silent Notification) — they don’t present badges, alerts, or sounds.

2. Apple promises to deliver the iOS push notifications with high priority.

3. For Voice over Internet Protocol (VoIP) push notifications, the maximum payload size is 5 KB (5120 bytes).

4. Your device is woken only when VoIP pushes occur, saving energy.

5. VoIP push can include more data than what is provided with standard push notifications.

6. If your app is not running when a VoIP push is received then your app is automatically relaunched.

7. Your app is given a runtime to process the push, even if it is operating in the background.


Enable Voice over IP in your project

Picture1

Xcode Project > Capabilities pane. Select the checkbox in Background modes for Voice over IP, as per the image shown above.


Prepare to Receive VoIP Push Notifications

You must also create a certificate for your VoIP app. Each VoIP app requires its own individual VoIP Services certificate, mapped to a unique App ID. This certificate allows your notification server to connect to the VoIP service.

Visit the Apple Developer https://developer.apple.com/certificates and create a new VoIP Services Certificate.

However, push certificates can be re-used for development and production both. See the image below to know.

Picture2

After doing that import the VoIP Push Certificate into Keychain Access and export it as a .p12 file. Create an iOS app and upload the VoIP push certificate for both Production and Development environments. Enable push notification.

Download the certificate and import it into the Keychain Access app.
Then export certificate for creating .pem file

Create .pem file from an exported certificate.

Now, navigate to the folder where you exported this file and execute following command:
openssl pkcs12 -in YOUR_CERTIFICATES.p12 -out VOIP.pem -nodes -clcerts


Configure VoIP Push Notifications in Xcode project (Swift)

To configure your app to receive VoIP push notifications, link to the PushKit framework in your app delegate (or some other location in your app), and after that we have to create a PKPushRegistry object and set its delegate to self, and register to receive VoIP pushes.

Picture3

Now, implement a delegate method that can handle updated push credentials. If your app receives both standard push notifications and VoIP pushes, then your app will receive two separate push tokens. Both tokens must be passed to the server in order to receive notifications.

Finally, set up a delegate method to process pushes. If your app isn’t running when the push is received, your app will be launched automatically.

Picture4


Test:

You can test VoIP notification by using the following code in terminal:

curl -v -d '{"aps":{"caller":"Caller Name"}}' --http2 --cert VOIP.pem:password https://api.development.push.apple.com/3/device/voip_device_token


Note:

On iOS 13.0 and later, incoming Voice over IP calls must be reported when they are received and that also before the didReceiceIncomingPush() method finishes execution, otherwise the system will terminate your app. Repeatedly failing to report calls may prevent your app from receiving any more incoming call notifications. Basically what that means is, you shall not use VoIP pushes for non-VoIP messaging, and shall use regular push notifications for that.

What OdiTek offers


Refer our Skills page:

WebRTC for Telecoms

WebRTC is a free and open source application framework which utilises simple APIs to provide browsers and mobile apps, the real time communications(RTC) capabilities over peer-to-peer connections. The components of WebRTC have been carefully optimized to best serve the above said purpose. Further it allows...

more

Client Testimonials

We had a tough deadline to launch our .Net based application that processes a lot of data, and got very frustrated with our development agency we hired. Fortunately we got Oditek, and they took over seamlessly the product development, launched the app & continued feature development. Just awesome!

Neal Bonrud

Co-Founder – SubScreener, USA

They were very attentive to our needs as clients and went out of the way to make sure our projects were taken care of. They were always able to get projects done in the specifications we requested. They are passionate about getting things done; I would definitely recommend them to lead any IT projects.

Dann Manahan

Sr VP Technology- 1031 Crowd Funding

I worked with OdiTek on few high profile banking application projects. They did a fantastic job with web applications & manual testing on the VAS apps for two leading banks of UK that included rigorous UAT phases. I recommend them for any application development where security matters.

Clive Shirley

CTO- Smarta, UK

OdiTek is our extended team who works on our key software projects. They are dependable, good in collaboration and technically very much to the level what we expect a global team should be. They had transformed our web applications, CRM and added mobility to existing business platforms here.

Matt Berry

IT Manager- First Option Online

It's been more than 4 years now that we are working with OdiTek on our cloud based web product development. It's been amazing working together, they are very competent on designing scalable, high performance apps. Their technical support is outstanding to say the least, even at odd hours.

Brad Taylor

CEO- BluesummitTech, USA

I am a fan of Team OdiTek since 2014 and have worked on many product development projects together. Specially worth mentioning their deliveries on VAS Banking web application development & manual testing services for Smarta, UK. They are highly skilled & a professional team to work with.

Tom Bowden

Digital Propositions - HSBC, London

OdiTek has been working on our Integrated Web-scale Mobile Platform i.e. Optimal Health since 2014. They are very professional and takes care of the requirements meticulously. They are technically very sound and sincere in ensuring quality & performance. Wonderful working with them!

Catherine Lim

COO- Medilink Global Sdn Bdh

You can trust the team, with minimum supervision you get the work done. They are honest, professional & committed to schedule & quality. I had been successfully running 3 business applications designed, developed and maintained by Oditek developers. It’s been a pleasure working with them.

Scott Evans

CEO- Pink Storage, UK

OdiTek has been working in custom software development, including services for test automation. Many of them have worked with me in 2009-10 when I was R&D Manager in NetHawk India. They have great enthusiasm & a passion to excel in bringing customer success. Their work has been very impressive.

Karen Hamber

Senior Product Manager- Skype

It's amazing to see these guys are turning their experience into a global delivery excellence at OdiTek. I am sure their past large scale product development experience will be handy to product companies. I would always recommend Oditek for software development, especially performance-driven solutions.

Juha Marjeta

Opti Automation Oyj

If you need additional information or have project requirements, kindly drop an email to: info@oditeksolutions.com

×