twilio / twilio-voice-react-native

Other
62 stars 22 forks source link

Is there a way to set caller name when the application is closed? #361

Open bojandurmic opened 2 months ago

bojandurmic commented 2 months ago

Hey everyone,

I am using version 1.0.0 of SDK. I have a small issue. When receiving the incoming call, and the app is running, this code works great:

const { displayName, companyId } = callInvite.getCustomParameters();
await callInvite.updateCallerHandle(displayName);

However, if the app is closed, users only see an E.164 formatted phone number.

Is there any API or anything that we can send from Twilio side that will let us customize the caller name if the app is closed as well? Thanks!

bobiechen-twilio commented 2 months ago

Hi @bojandurmic

Your application should be woken up by the incoming call push notification and can call the SDK methods to update the caller name. Are you not getting the incoming call event in the React Native layer?

bojandurmic commented 2 months ago

Hey @bobiechen-twilio

I am not getting the incoming call event in RN layer. The incoming call even will happen if the app is in the background. But if the app is force closed, and a call is made, then nothing happens and CallKit just shows the from parameter (which is a phone number).

Should Twilio's SDK wake up the app and have the events called even if the app is force closed?

bobiechen-twilio commented 2 months ago

Thanks for the update @bojandurmic

The fact that you saw the system phone UI by CallKit indicates that the app was launched from terminated state so the app and the SDK are able to process the push notification as a call invite.

I'll work with our JavaScript experts to see if there is a way (or not) to raise the incoming call invite event to the JS layer in this case.

bojandurmic commented 2 months ago

I am not sure I follow.

The situation where I am able to set caller handle happens only when the app is running in the background or is open in the foreground. I handle this in JavaScript layer.

I guess my question is what we can do when the app is closed and JS layer hasn't opened yet?

Do you know how we can do it on native layer? Any help would be greatly appreciated. Thanks!

bojandurmic commented 2 months ago

Hi @bobiechen-twilio , just want to make sure you got my message above.

We don't have any issues with forking the package and implementing what we need ourselves. If you could just guide us how to do that on the native layer (which files/methods to update), I'd greatly appreciate it :)

bobiechen-twilio commented 2 months ago

Hi @bojandurmic sorry if I haven't responded back sooner.

Currently the SDK (native Objective-C layer) takes care of reporting the new incoming call using the value of callInvite.from. This is place where it's happening: https://github.com/twilio/twilio-voice-react-native/blob/main/ios/TwilioVoiceReactNative%2BCallKit.m#L70. Here you can inject your business logic and use the value that makes sense for the incoming call handle/name.

bojandurmic commented 2 months ago

Hi @bobiechen-twilio thanks a lot! What about Android?