twilio / voice-quickstart-ios

Twilio Voice Quickstart for iOS with Swift
MIT License
182 stars 96 forks source link

iOS 13 App built on Xcode 11 Crashes when receiving call if the app is on background or killed #308

Closed fmonsalvo closed 1 year ago

fmonsalvo commented 4 years ago

Description

I have a react-native application that use a home built component to handle Twilio communication. We have upgraded to latest 5.x twilio iOS SDK and latest Android SDK. On Android it works great. On iOS the calls work perfect when the app is in foreground but it fails when the app is killed and the phone locked. I followed all the issues and the migration guides to no avail. I'm sure there's something wrong in the code as I'm experiencing what is described in issue #251 but I'm not sure what's wrong. When the phone is killed pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler is never called and then I get an error saying Killing VoIP app <private> because it failed to post an incoming call in time.

Steps to Reproduce

  1. Launch application in iphone with iOS 13.x and log in. Make sure Twilio is registered
  2. Kill the app and lock the phone
  3. Call the locked phone.
  4. Application starts in XCode Debug, but is killed with Killing VoIP app <private> because it failed to post an incoming call in time. Error.

Expected Behavior

That I receive a call

Actual Behavior

Nothing happens.

Reproduces How Often

Always

Versions

Voice iOS SDK

5.1.1

Xcode

11.3.1

iOS Version

13.3.1

iOS Device

iPhone 6s Plus

PCGurjar commented 3 years ago

Hi @bobiechen-twilio

  1. I am using twillio video pod 2.0 Yes , I am able to receive push notifications when the app is active? 3.0 getting, [PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes] + 212 (PKPushRegistry.m:353) in crash logges. but after getting Voip I already report a call to callkit (by using method reportIncomingCall) 4.0 Is the PkPushRegistry object created at app launch? = I am initiated this in DidFinishLauncing
bobiechen-twilio commented 3 years ago

Hi @PCGurjar Sounds like in some cases, especially when the app is terminated and the VoIP notification arrives, the application is not reporting to CallKit in a timely manner. Please check the behavior of the app when incoming call VoIP push is received in different app states - active, background, not running (terminated).

Our quickstart sample code should provide the way how to set up the PkPushRegistry at app launch time and handle incoming pushes including signaling other components and reporting to CallKit.

By the way just want to make sure - are you using the Twilio Video SDK or the Voice SDK?

PCGurjar commented 3 years ago

Hi @bobiechen-twilio I am using Video SDK for this.

bobiechen-twilio commented 3 years ago

Hi @PCGurjar

Please check out the Video or Voice quickstart and make sure your native code follows Apple's guideline.

anas-p commented 3 years ago

Do this first, Important!

Screenshot 2021-03-26 at 10 12 06 AM Screenshot 2021-03-26 at 10 15 36 AM

Add below code is inside : func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void)

Screenshot 2021-03-26 at 10 13 45 AM

Use completion() in main thread.