Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Notification : How does WhatsApp receive notification and process even after force closing them?

I am building an iOS App ( Using Swift) where I want like to process Notification even though my app has been closed (force closed).

  • I am receiving a Notification alert, however it is not processed till user click on notification badge.

  • However, when I check notification behavior or WhatsApp is seema notification get process even though Whatsapp is closed before use tap on notification badge.

  • I have search across forums and all most ever where it has been mention that your notification can not process if App is not running. ( It can process if App is in Background or Foreground )

My Question : If as per Apple documentation if App can not process the notification if it is not running then how Whatsapp has managed to do so.

How can I achieve same behavior at my app ?? I will highly appreciate for right technical solution and I believe there are hundreds of developers might have same query.

like image 414
Dhaval Patel Avatar asked Dec 30 '25 05:12

Dhaval Patel


1 Answers

As WhatsApp is a VoIP application, it is entitled to use PushKit:

PushKit notifications differ from the ones you handle using the UserNotifications framework. Specifically, PushKit notifications never display alerts, badge your app's icon, or play sounds. They also have the following advantages over user notifications:

  • The device wakes only when it receives a PushKit notification, which can improve battery life.
  • Upon receiving a PushKit notification, the system automatically launches your app if it isn't running. By contrast, user notifications aren't guaranteed to launch your app.
  • The system gives your app execution time (potentially in the background) to process PushKit notifications.
  • PushKit notifications can include more data than user notifications.

Note the second bullet point.

If your app meets the criteria for PushKit use (VoIP app, Watch Complication update or file provider update) then you can use it.

Update

In iOS 13 and later an app must report an incoming CallKit call in response to a VoIP push or it will be terminated. This means that in general VoIP or PushKit pushes cannot be used for messaging or other purposes, but WhatsApp doesn't do this. How?

They have a restricted entitlement com.apple.developer.pushkit.unrestricted-voip.

This entitlement is not granted any more and was intended to give apps with millions of users more time to adopt the new approach.

like image 156
Paulw11 Avatar answered Dec 31 '25 18:12

Paulw11