MrHertal / react-native-twilio-phone

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

callKeepOptions is missing in android platform #76

Closed jackywxd closed 2 years ago

jackywxd commented 2 years ago

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).

Fix for issue #75

armouti commented 2 years ago

@jackywxd this is not enough. When the app is killed, the variable RNTwilioPhone.callKeepOptions is cleared, so when RNTwilioPhone.handleBackgroundState is invoked after the app is killed RNTwilioPhone.callKeepOptions is undefined. The solutions is for RNTwilioPhone.handleBackgroundState to accept callKeepOptions itself, like this:

static handleBackgroundState(callKeepOptions: IOptions) {
  ...
  RNCallKeep.registerPhoneAccount(RNTwilioPhone.callKeepOptions || callKeepOptions);
  ...
}
MrHertal commented 2 years ago

Thanks @jackywxd for creating this PR and thanks @armouti for your feedback. I have included these changes in a more global update of this module:

https://github.com/MrHertal/react-native-twilio-phone/releases/tag/v1.9.0

It should work properly now. I will close that PR.