MrHertal / react-native-twilio-phone

Twilio Voice React Native module.
MIT License
153 stars 66 forks source link

Android RNCallKeep.registerPhoneAccount is missing callKeepOptions #75

Closed jackywxd closed 2 years ago

jackywxd commented 2 years ago

Thanks for your efforts to create such wonderful package! It saved me days for one of my projects.

In methods: initializeCallKeep and handleBackgroundState, RNCallKeep.registerPhoneAccount() is called without passing the required callKeepOptions. This will prevent the CallKeep from handling incoming calls in background, and will get error:

[TypeError: Cannot read properties of undefined (reading 'android')]

Because callKeepOptions was missing (undefined).

A simple solution is to add: static callKeepOptions: IOptions

to save the callKeepOptions in initialize(), and pass it to RNCallKeep.registerPhoneAccount.

Hope this can help and thanks again!

vjhameed commented 2 years ago

Hey how did you fix this ?

jackywxd commented 2 years ago

@vjhameed I used patch-package to patch it without updating the original npm package. Below is the patch file:

class RNTwilioPhone { static calls: Call[] = [];

MrHertal commented 2 years ago

Hi, thank you for reporting that issue. Could you submit a PR?

jackywxd commented 2 years ago

@MrHertal Sure will do.

vjhameed commented 2 years ago

@jackywxd could you also drop the fcm payload example ? i keep getting the invalid twillio voice sdk payload error.

Thanks man

jackywxd commented 2 years ago

@vjhameed If you are getting invalid twilio voice sdk payload error, that's different issue. You probably should revisit your project configurations following the twilio voice sdk documentations.

I don't have fcm payload example for this case.

Good luck!

vjhameed commented 2 years ago

I did go through the documentation a thousand times. The use case on my end is that i want to receive calls on the react antive app. But when twillio hits the backend webhook i don't know what payload to send in the push notification to the react native app

jackywxd commented 2 years ago

I think you have misconception of the whole workflow. what Twilio expects from webhook is TwiML response. After that VOIP push notification is handled by Twilio, not by webhook. There are more details in Twilio's documentation about how to setup VOIP certificates.

Good luck!

vjhameed commented 2 years ago

@jackywxd can you please do me a favor and explain the worflow in steps. would really help alot.

Thanks a thousand times dude

vjhameed commented 2 years ago

@jackywxd can you please help mate

jackywxd commented 2 years ago

@vjhameed I don't think I can do a better job than Twilio. As I said Twilio has done a pretty good job in terms of documentation. If it doesn't make sense for you, nor can I make it clear.

armouti commented 2 years ago

@MrHertal @vjhameed @jackywxd that fix alone isn't enough for when the app is killed, check https://github.com/MrHertal/react-native-twilio-phone/pull/76#issuecomment-1051023132

theol93 commented 2 years ago

have same problem, waiting for PR #76

MrHertal commented 2 years ago

I have released https://github.com/MrHertal/react-native-twilio-phone/releases/tag/v1.9.0 which contain a fix for that issue. Thanks!