twilio / voice-quickstart-ios

Twilio Voice Quickstart for iOS with Swift
MIT License
183 stars 97 forks source link

iOS 15.2 Apps built on Xcode 13.2 app is terminating on TwilioVoiceSDK.handleNotification #489

Closed warisappify closed 2 years ago

warisappify commented 2 years ago

I am facing issue in iOS 15.2 with iOS Voice SDK 6.3.0

Call works perfectly fine when app is in active state but when app goes in BackGround or app is killed then call didn't work. Here are the logs for help.

App crash on this line TwilioVoiceSDK.handleNotification(payload.dictionaryPayload, delegate: self, delegateQueue: nil)

2022-01-07 20:59:23.333373+0500 myApp[2296:450716] pushRegistry:didReceiveIncomingPushWithPayload:forType:completion: 2022-01-07 20:59:27.376857+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call create 2022-01-07 20:59:27.377426+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating peer connection signaling thread ... 2022-01-07 20:59:27.377859+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating peer connection worker thread ... 2022-01-07 20:59:27.378478+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating peer connection networking thread ... 2022-01-07 20:59:27.378834+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating media engine ... 2022-01-07 20:59:27.379531+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Done creating media engine. 2022-01-07 20:59:27.379777+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating peer connection factory ... 2022-01-07 20:59:27.381013+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Done creating peer connection factory. 2022-01-07 20:59:27.381914+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call handleMessage 2022-01-07 20:59:27.382242+0500 myApp[2296:450716] INFO:Twilio:[Core](Thread 0x0x111bd3b80): Creating dedicated notifier queue ... 2022-01-07 20:59:27.383071+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Selected edge - roaming Selected region - gll 2022-01-07 20:59:27.383386+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Initializing SIP stack ... 2022-01-07 20:59:27.388201+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Adding IPv4/IPv6 TLS transports ... 2022-01-07 20:59:27.388801+0500 myApp[2296:450716] INFO:Twilio:[Signaling](Thread 0x0x111bd3b80): RESIP::TRANSPORT: Connection::Connection: new connection created to who: [ V4 0.0.0.0:0 UNKNOWN_TRANSPORT target domain=unspecified mFlowKey=0 ] 2022-01-07 20:59:27.389539+0500 myApp[2296:450716] INFO:Twilio:[Signaling](Thread 0x0x111bd3b80): RESIP::TRANSPORT: Creating TLS transport for domain interface= port=0 2022-01-07 20:59:27.390416+0500 myApp[2296:450716] INFO:Twilio:[Signaling](Thread 0x0x111bd3b80): RESIP::TRANSPORT: Connection::Connection: new connection created to who: [ V4 0.0.0.0:0 UNKNOWN_TRANSPORT target domain=unspecified mFlowKey=0 ] 2022-01-07 20:59:27.390756+0500 myApp[2296:450716] INFO:Twilio:[Signaling](Thread 0x0x111bd3b80): RESIP::TRANSPORT: Creating TLS transport for domain interface= port=0 2022-01-07 20:59:27.391482+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Initializing DUM ... 2022-01-07 20:59:27.392025+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Starting SIP stack thread ... 2022-01-07 20:59:27.392651+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Starting DUM thread ... 2022-01-07 20:59:27.393282+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getSignalingThread 2022-01-07 20:59:27.393797+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getNetworkingThread 2022-01-07 20:59:27.394173+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): <0x116114400> initializeThreadCheckers 2022-01-07 20:59:27.394695+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): <0x116114400> initialize 2022-01-07 20:59:27.394943+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): <0x282b97480> Starting the Network Manager 2022-01-07 20:59:27.395173+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): <0x2823a4840> RtcMonitor 2022-01-07 20:59:27.395499+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): AppleReachability::AppleReachability() 2022-01-07 20:59:27.395822+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Creating zeroAddrReachability 2022-01-07 20:59:27.397345+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getFrom 2022-01-07 20:59:27.397580+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): listen 2022-01-07 20:59:27.398005+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getFrom 2022-01-07 20:59:27.398374+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getTo 2022-01-07 20:59:27.398916+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getCallSid 2022-01-07 20:59:27.399307+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getFrom 2022-01-07 20:59:27.399663+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getTo 2022-01-07 20:59:27.400235+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getCallSid 2022-01-07 20:59:27.400745+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): ListenerImpl 2022-01-07 20:59:27.401065+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): Started listen no-op timer for 39997 ms 2022-01-07 20:59:27.401615+0500 myApp[2296:451653] DEBUG:Twilio:[Core](MediaFactoryImpl::signaling 0x0x283a74b00): twilio::voice::AsyncDnsResolver::AsyncDnsResolver(std::weak_ptr) 2022-01-07 20:59:27.401888+0500 myApp[2296:451653] DEBUG:Twilio:[Core](MediaFactoryImpl::signaling 0x0x283a74b00): AsyncDnsResolver resolving hostname = chunderm.gll.twilio.com 2022-01-07 20:59:27.402597+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getCallSid 2022-01-07 20:59:27.402985+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getTo 2022-01-07 20:59:27.403510+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getCallerInfo 2022-01-07 20:59:27.405840+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): isVerified 2022-01-07 20:59:27.405907+0500 myApp[2296:451658] dnssd_clientstub write_all(37) DEFUNCT 2022-01-07 20:59:27.405972+0500 myApp[2296:451658] dnssd_clientstub deliver_request ERROR: write_all(37, 80 bytes) failed 2022-01-07 20:59:27.406166+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): isVerified 2022-01-07 20:59:27.406779+0500 myApp[2296:451658] dnssd_clientstub write_all(37) DEFUNCT 2022-01-07 20:59:27.407572+0500 myApp[2296:450716] Call invite received from verified caller number! 2022-01-07 20:59:27.408593+0500 myApp[2296:450716] DEBUG:Twilio:[Core](Thread 0x0x111bd3b80): API Call getFrom 2022-01-07 20:59:27.410074+0500 myApp[2296:450716] Apps receving VoIP pushes must post an incoming call via CallKit in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay. 2022-01-07 20:59:27.410683+0500 myApp[2296:450716] Assertion failure in -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes], PKPushRegistry.m:352 2022-01-07 20:59:27.412280+0500 myApp[2296:450716] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push.** First throw call stack: (0x184419d3c 0x19b77e6a8 0x185bea99c 0x1ba01003c 0x110395f94 0x1103a5638 0x1ba00f35c 0x110394718 0x110395f94 0x1103a4758 0x1843d5888 0x184393188 0x1843a5e1c 0x1a47009a0 0x186bd9600 0x18696eb08 0x104081228 0x10deb4250) libc++abi: terminating with uncaught exception of type NSException

bobiechen-twilio commented 2 years ago

Hi @warisappify

Please follow the migration guide and make sure your application reports to CallKit immediately upon receiving the VoIP push notification. You can also check out how the quickstart does this. Remember:

  1. Initialize your PushKit instance in AppDelegate to ensure it gets created at app launch
  2. Report to CallKit immediately upon receiving the VoIP push notification
warisappify commented 2 years ago

Ooohh man i think you didn't read the description and close the issue. If i didn't follow the migration and other steps you mention then why call received in active state?

bobiechen-twilio commented 2 years ago

The app is getting terminated because the app fails to follow the policy of PushKit + CallKit, as indicated in the debugging log. This has been reported multiple times and this happens especially when the app is not active. Make sure you follow the implementation best practice in our quickstart and apply necessary changes to your application.

warisappify commented 2 years ago

I did everything mention in your guidelines but nothing works. After that i tried in your sample code and there is no call in background in your sample code too. You have to look into this seriously. I know that it's reported many times but i am reporting it for iOS 15.2 and Xcode 13.2. Also for your information i am using this from version 3.x. And call is working perfectly fine in Active, Background and Killed state. But suddenly after this update it's not working.

@bobiechen-twilio kindly look into the lib and test your sample code for the scenario and then came back to me. Thanks.