I have a IOS app made in Xamarin that has VOIP Push capabilities. I am trying to replicate What's App VOIP call funcationality. So when I turn off the IOS device and turn it back on and then try to receive a voip push and report it to callkit, the console log shows "Killing VoIP app because it failed to post an incoming call in time." before my app has even OnFinishedLaunching has finished and before IncomingPushReceived is even called. However subsequent voip pushes work just fine.
I fairly new to IOS so I'm not sure why this is the case. The only thing I can think of is that it takes too long for my app to launch.
Any insight will be helpful.
Thank you very much
Here is my code:
public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
Instance = this;
//output what state the app is in. This will be used to see when the app is started in the background
app.IdleTimerDisabled = true;
RegisterPushKit();
InitializeFirebaseMessagingDelegate();
InitializeBackgroundTasks();
HandleNotificationOnLaunch(options);
try {
InitializingNugetPackages();
SaveAudioStreamSession();
SubscribingToLongingRunningTaskMessage();
TwilioAudioManager.InitailizeAudioDevices();
} catch (Exception exce) {
} finally {
LoadApplication(xamapp);
}
return base.FinishedLaunching(app, options);
}
public void DidReceiveIncomingPush(PKPushRegistry registry, PKPushPayload payload, string type, Action completion) {
void IncomingPushKitCompletion() {
completion();
};
bool mainThread = NSThread.IsMain;
try {
IDictionary < string, object > Data = payload.DictionaryPayload.ToAPNsDictionary();
Dictionary < string, string > data = new Dictionary < string, string > (Data.ToStringDictionary());
if (type.EqualsIgnoreCase(PKPushType.Voip)) {
string twiMessageType = string.Empty;
if (data.TryGetValue("twi_message_type", out twiMessageType) || data.TryGetValue("twili_message_type", out twiMessageType)) {
if (twiMessageType == "twilio.voice.call") {
// Handle Twilio Voice call
HandleIncomingVoiceCall(data);
} else if (twiMessageType == "twilio.video.call") {
// Handle Twilio Video call
HandleIncomingVideoCall(data);
} else {
// Invalid push payload, complete the call handling
ProviderDelegate.ReportFakeIncomingCall(new NSUuid());
}
} else {
// Invalid push payload, complete the call handling
ProviderDelegate.ReportFakeIncomingCall(new NSUuid());
}
} else {
// Not a VoIP push, complete the call handling
ProviderDelegate.ReportFakeIncomingCall(new NSUuid());
}
} catch (Exception ex) {
ProviderDelegate.ReportFakeIncomingCall(new NSUuid());
IncomingPushKitCompletion();
} finally {
IncomingPushKitCompletion();
}
}
I tried to remove and strink my OnFinishedLaunching so that IncomingPushReceived could get called faster. However this didn't work.