Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call not coming when app is in background in iOS #167

Open
suny2talk opened this issue Nov 19, 2020 · 13 comments
Open

Call not coming when app is in background in iOS #167

suny2talk opened this issue Nov 19, 2020 · 13 comments

Comments

@suny2talk
Copy link

I have used TwilioVoice (5.2.1) and RNTwilioVoice (4.1.0)..My react native version is "react-native": "0.63.3",..
Received call when app is in foreground, but do not get call when the is in background in iOS 13..Please help me to do that..

Thanks

Originally posted by @suny2talk in #165 (comment)

@jdegger
Copy link
Collaborator

jdegger commented Nov 20, 2020

Please provide code examples of what you are doing. Make sure that your voip push certificate is proper.

@suny2talk
Copy link
Author

Please provide code examples of what you are doing. Make sure that your voip push certificate is proper.

My voip push certificate is proper I think, because I have received the call when my app is on foreground..but don't receive the call when I have terminated the app..for code example what you want to check? should I post the call screen page where I will implemented the call listeners?

@suny2talk
Copy link
Author

@jdegger sir,
please help me..I am stuck on this..

@fmonsalvo
Copy link
Contributor

Hi @suny2talk what @jdegger is asking you to do is to add more information to the issue so we can understand what is going on.
There are a couple things that could go wrong with iOS and Callkit.
Can you please answer the questions below?
Please include the following information for better support

The more context you provide around this issue the faster the community can help you

Did you follow all the instructions as specified in the Twilio Quickstart repositories?
What version of React Native are you running?
What version of react-native-twilio-programmable-voice are you running?
What device are you using? (e.g iOS10 simulator, Android 7 device)?
Is your app running in foreground, background or not running?
Is there any relevant message in the log?
If using iOS, which pod version are you using?

Step to reproduce

Advanced:
Have you tried adding break point using AndroidStudio or XCode and analyse the logs?
can share a project with issue?
Did you try to reinstall the pods completely?

How are you handling the react-native-twilio-programmable-voice on the javascript side of things?
Can you please add some code?
Have you tried adding a breakpoint in didReceiveIncomingPushWithPayload and see if you get the notification when in background?

@suny2talk
Copy link
Author

@fmonsalvo ,
Thanks for your reply,

Did you follow all the instructions as specified in the Twilio Quickstart repositories?

  • I have followed all steps.

What version of React Native are you running?

  • "react-native": "0.63.3",

What version of react-native-twilio-programmable-voice are you running?

  • "react-native-twilio-programmable-voice": "^4.1.0",

What device are you using? (e.g iOS10 simulator, Android 7 device)?

  • I have used iPhone 6s (iOS 14.0.1) and iPhone XR (13.7).. When I have integrate old version and check in iOS 12 in same phone its working properly..

Is your app running in foreground, background or not running?

  • In the state foreground and background the call is coming properly, also open the iOS call kit..But my problem is arise on not running state..Its ringing but call is not coming..

Is there any relevant message in the log?

  • In foreground: 2020-11-26 02:17:35.421507+0530 PhoneApp[885:688988] pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler
    2020-11-26 02:17:35.492775+0530 PhoneApp[885:688988] callInviteReceived
    2020-11-26 02:17:36.010137+0530 PhoneApp[885:688988] Incoming call successfully reported
    2020-11-26 02:17:41.475488+0530 PhoneApp[885:688988] cancelledCallInviteReceived with error
    2020-11-26 02:17:41.481342+0530 PhoneApp[885:688988] provider:performEndCallAction

  • In background: 2020-11-26 02:18:14.153728+0530 PhoneApp[885:688988] pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler
    2020-11-26 02:18:14.158802+0530 PhoneApp[885:688988] callInviteReceived
    2020-11-26 02:18:14.186637+0530 PhoneApp[885:688988] Incoming call successfully reported
    2020-11-26 02:18:18.150213+0530 PhoneApp[885:688988] cancelledCallInviteReceived with error
    2020-11-26 02:18:18.154335+0530 PhoneApp[885:688988] provider:performEndCallAction

  • After that I have terminate the app no call is reported..But when I have opend it again then I have found the below errors,
    2020-11-26 02:36:03.726781+0530 PhoneApp[2801:8693940] Apps receving VoIP pushes must post an incoming call (via CallKit or IncomingCallNotifications) in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay.
    2020-11-26 02:36:03.727203+0530 PhoneApp[2801:8693940] *** Assertion failure in -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes], /Library/Caches/com.apple.xbs/Sources/PushKit/PushKit-37/PKPushRegistry.m:343
    2020-11-26 02:36:03.728021+0530 PhoneApp[2801:8693940] *** 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 callback.'

If using iOS, which pod version are you using?

  • pod version: 1.10.0

My phone dialler screen code below,

PhoneDialerScreen.js.zip

@jdegger
Copy link
Collaborator

jdegger commented Nov 26, 2020

I expect this is a bug with our repo or with the docs we are providing with the repo. The actual error you are facing is:

Apps receving VoIP pushes must post an incoming call (via CallKit or IncomingCallNotifications) in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay.

However, we are currently not facing this issue in our own app. I will try and see if we can find the difference between our app and your implementation.

@suny2talk
Copy link
Author

@jdegger ,
Thanks for your reply.
The issue is when app is in terminated state VoIP push is coming but not reported the CallKit I think. Thats why when we open the app again app is crash. I think this is happen for below code,
in the method "didReceiveIncomingPushWithPayload"
// Save for later when the notification is properly handled.
self.incomingPushCompletionCallback = completion;

Anyway, in terminated state CallKit not working this is the main issue..
Please check my code and let me know if any issue in it..It is totally dynamic.

@TheRohitSharma
Copy link

@suny2talk Are you sure you have these background modes selected in your app's capabilities?
xcode-project-capabilities

@suny2talk
Copy link
Author

@TheRohitSharma ,
Yes I have done this things..Please find the screenshot..

Screenshot 2020-12-01 at 5 25 38 PM

@suny2talk
Copy link
Author

@jdegger ,
Sir do you find any solution in this issue? Please let me know..

@dakenf
Copy link
Contributor

dakenf commented Dec 14, 2020

I have realized that issue is very easy to reproduce: you need to request twilio token from server each time you launch the app
For example

const token = await api.getToken()
TwilioVoice.initwithToken(token)
TwilioVoice.configureCallKit(...)

This way RNTwilioVoice.initPushRegistry will only be called after you receive the token from the backend and by that time iOS can kill the app. My workaround allows calling RNTwilioVoice.initPushRegistry and configureCallKit from objective-c without relying on the JS code and having the token

@salman-pixarsart
Copy link

I'm also facing the same issue. Sometimes I receive call in the background mode and when the app is in quit state but sometimes I don't.
@dakenf Can you please share your workaround code snippet here?

@milo-sedarat
Copy link

Hi, @jdegger @suny2talk Did you resolve this issue? Actually, I am facing the exact same issues. Only sometimes, I can't receive the call at the killed state. But sometimes can also receive.

image

Can you please give me some tips?

Best Regards,
Vernon G.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants