[NOTE: This question is about VoiP pushes, not about ordinary pushes]
If the app is terminated and a Voip push arrives then within didFinishLaunchingWithOptions the options a nil. (This can be contrasted against if an app is launched when the user taps on a local notification for example).
How does an app know its being launched due to the arrival of a VoIP push, as opposed to a push arriving while the app is already in the background?
1 Answers
Answers 1
You need to set a delegate to the PKPushRegistry
object you have created and specify it as a VOIP type:
let voipRegistry = PKPushRegistry(queue: nil) voipRegistry.delegate = myPushDelegate voipRegistry.desiredPushTypes = [PKPushType.voIP]
Your delegate will have to conform to the PKPushRegistryDelegate
protocol.
Then, implement the pushRegistry(_:didReceiveIncomingPushWith:for:completion:)
protocol function (reference) - this function will be called upon receiving a push (even if at the app was terminated earlier).
the function description:
Notifies the delegate that a remote push has been received.
the specified push type. Call the completion handler as soon as you have finished processing the payload.This method is invoked when a push notification has been received for
please note thet the function: pushRegistry(_:didReceiveIncomingPushWith:for:)
has been deprecated so don't be confused with the one I mentioned above.
More information about the PKPushRegistryDelegate
protocol: here
About the actual question, there is a work around for that - create a flag that will be destroyed when app will terminate but as soon as it wakes up it status will change - if the app woke up from background the flag status will be saved but if the app woke up after it was terminated the flag will hold the default value.
0 comments:
Post a Comment