Reputation: 648
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.
Upvotes: 3
Views: 1684
Reputation: 114965
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.
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.
Upvotes: 6