I'm developing a VoIP app using PushKit and CallKit. I'm aware that similar questions have been asked quite often on different forums but unfortunately have never really been answered. Also most of these posts are from around 2015 so i assume chances are a lot has been changed in terms of someone might have figured meanwhile how to get this working.
What's working:
When the app is running in foreground or sent to background it receives push notifications using the sandbox server as well is the production server.
I'm on iOS 11 and Xcode 9 and needed to enable the regular push notifications in 'capabilities' as well as manually adding the voip background mode to the info.plist for the delegate methods to get called. Linking CallKit and PushKit alone was not enough to receive notifications. I also enabled Background Audio, Background fetch and Remote Notifications. I also created a background task before doing the push registry registration and i end that task after receiving the push token.
What's not working:
Waking up the app after reboot or force quit on incoming calls.
I see the process launching on incoming calls in the Instruments activity monitor though but it looks like something's not working from there since i don't get the incoming call ui.
Questions:
- When the app is not running what's the entry point on an incoming notification?
-pushRegistry:didReceiveIncomingPushWithPayload:forType:
or maybe (only)-application:didFinishLaunchingWithOptions:
? - I stored my credentials to register with the server in the keychain. is it possible that there's a point during application launch when it's too early to query the keychain for something?
UPDATE:
figured a solution myself. this was more a timing issue between client and server. so this is what worked for me.
- send the push from the server which launches the app
- give the app some time to launch and reregister at the sip server after receiving the push
- send the INVITE the client using the latest registration information
also important is not calling the completion handler on the push notification delegate too early which will put the app back to sleep and the INVITE will never be received.
also maybe helpful and something that would make the scenario a little more forgiving. if your sip server sends the invite a couple of times make sure that on each of them always the latest registration information is being used. meaning.. let's say the first INVITE is sent too early to some outdates registration information and the client still launches trying to update that information on the server... make sure the next one uses the updated information. some sip server simply use the first information available for each iteration. and so you would wait forever without receiving anything on the client.