MrHertal / react-native-twilio-phone

Twilio Voice React Native module.
MIT License
154 stars 67 forks source link

Getting Custom Parameters from incoming calls. #56

Closed dchannell closed 2 years ago

dchannell commented 3 years ago

Is it possible to get custom parameters twi_params passed along with call data sent with the twilioPhoneEmitter events -- more specifically the CallInvite event type?

I've found a way to retrieve customParameters using RNVoipPushNotification.

if (Platform.OS == "ios") {
    useEffect(() => {
      RNVoipPushNotification.addEventListener(
        "notification",
        (notification) => {
          delete notification.aps;

          console.log(notification.twi_params); // URL string with twi_params pass from TwiML app

          TwilioPhone.handleMessage(notification);
          RNVoipPushNotification.onVoipNotificationCompleted(notification.uuid);
        }
      );
      return () => {
        RNVoipPushNotification.removeEventListener("notification");
      };
    }, [false]);
  }

I also noticed that the TVOCallInvite [documentation] class has a property called customParameters.

I'm considering created a PR to add this functionality -- as it is a powerful way to pass along data to Twilio Apps to make more intuitive Call Answer Screens.

Just want to know if there is existing implementation / best practices for retrieving this info somewhere that I'm missing.

MrHertal commented 3 years ago

Hi, thanks for sharing this.

Just want to know if there is existing implementation / best practices for retrieving this info somewhere that I'm missing.

Maybe custom params could be also handled in the payload here.

as it is a powerful way to pass along data to Twilio Apps to make more intuitive Call Answer Screens.

Do you have an example in mind?