-->

Can I use PushKit to do regular push with out usin

2020-07-02 10:16发布

问题:

In the PushKit it is mentioned we can use regular push or VoIP push. But I did not find any documentation for what PKPushType to use for regular push. Did anybody try the regular push using the PushKit? If I don't use VoIP is it possible for a killed app to be launched in the background if it receives push notification? Meaning if app is killed and a notification comes and user does not act on it, can the app be launched by iOS in the background if I use PushKit?

回答1:

Since iOS 13.0, this is NOT allowed anymore. Apple will kill the app if failing to present CallKit before the didReceiveIncomingPush(withPayload:) is finished.

An Apple Employee answered a similar question in this thread and said the following:

On iOS 13.0 and later, incoming Voice over IP calls must be reported when they are received and before the didReceiceIncomingPush() method finishes execution, using the CallKit framework, or the system will terminate your app.

Repeatedly failing to report calls may prevent your app from receiving any more incoming call notifications.

Basically, you can no longer use VoIP pushes for non VoIP messaging, and will need to use regular push notifications for those.

This was announced during the WWDC session "Advances in App Background Execution" https://developer.apple.com/videos/play/wwdc2019/707/

So sadly not anymore. We will have to use the normal UINotification framework for "standard" push messages.



回答2:

I'm not sure what you mean by using "regular push" with PushKit, but you can use it to dispatch a notification regularly, although I think it will always execute your code, like a silent remote notification (maybe that's what you are wondering).

If you use PushKit, it does indeed launches an app when the notification is received, even if it was force-killed by the user. See this answer. I would just add that you probably need the Voice Over IP capability to achieve that effect.



回答3:

Another Important point need to be noted from documentation:

Unlike user notifications, which are supported by the UserNotifications framework, PushKit notifications are never presented to the user—they don't present badges, alerts, or sounds.



回答4:

Edit: This answer is not valid anymore.


Yes you can, check Apple Document

The PushKit framework provides the classes for your iOS apps to receive pushes from remote servers. Pushes can be of one of two types: standard and VoIP. Standard pushes can deliver notifications just as in previous versions of iOS.