twilio / twilio-voice-react-native

Other
62 stars 22 forks source link

CallInvite event not working on IOS #346

Closed devBjn closed 1 month ago

devBjn commented 3 months ago

Issue

Pre-submission Checklist

Description

Currently using 'twilio-voice-react-native' SDK version '1.0.0-beta.4'. The Voice event callInvite handler is not being executed when there is an incoming call

voice = new Voice();
await voice.initializePushRegistry();

const token = await getAccessToken();

// Allow incoming calls
await voice.register(token);

function handleCallInvite() {
  console.log("test");
}

voice.on("callInvite", handleCallInvite);

voice.on("error", (error) => {
  console.log("error", error);
});

console.log("done initialize");

Reproduction Steps

Expected Behavior

Log test when there is an incoming call

Actual Behavior

Nothing happend when there is an incoming call

Reproduction Frequency

Screenshots

If applicable, add screenshots to help explain your problem.

Software and Device Information

Please complete the following information.

Additional Context

I was testing using OpenPhone

mhuynh5757 commented 3 months ago

Hi @devBjn thanks for filling out the Issue Template. It helps us tremendously with debugging issues. Just to confirm, this is a physical iOS device you're using to test, not a simulator? Apple has limitations with simulators that we have no control over, incoming and outgoing calls will not work on a simulator.

If you are using a physical device, do you have the proper push credentials set up for the Apple Push Notification Service and a proper Twilio Push Credential set up with that APNS key pair?

If you can provide us with a CallSid, that would also be helpful.

devBjn commented 1 month ago

Hi @mhuynh5757 I have setup Twilio Push Credential with APNS key pair but it still not work I was using Twilio subaccount so I also setup the Push Credential in that subaccount but it still not working

here is the CallSid of the call

{
  Called: '+18735142014',
  ToState: 'QC',
  CallerCountry: 'CA',
  Direction: 'inbound',
  CallerState: 'QC',
  ToZip: '',
  CallSid: 'CA49f216b4289db8467917d9dc632afbb3',
  To: '+18735142014',
  CallerZip: '',
  ToCountry: 'CA',
  CallToken: '%7B%22parentCallInfoToken%22%3A%22eyJhbGciOiJFUzI1NiJ9.eyJjYWxsU2lkIjoiQ0E0OWYyMTZiNDI4OWRiODQ2NzkxN2Q5ZGM2MzJhZmJiMyIsImZyb20iOiIrMTgxOTIwMDU1NzUiLCJ0byI6IisxODczNTE0MjAxNCIsImlhdCI6IjE3MTU2NzcxNTEifQ.QnpZI3QtwauZwelPaM__x0fsypRlLXUMeg6anjnqVDOdRUpru1TAn5EqHqT3e-gHU2H1tM6GZVmQ3xthlEHnRg%22%2C%22identityHeaderTokens%22%3A%5B%5D%7D',
  CalledZip: '',
  ApiVersion: '2010-04-01',
  CalledCity: '',
  CallStatus: 'ringing',
  From: '+18192005575',
  AccountSid: 'ACa065a195d60c541416dcd40cf5e1ec02',
  CalledCountry: 'CA',
  CallerCity: 'CADILLAC',
  ToCity: '',
  FromCountry: 'CA',
  Caller: '+18192005575',
  FromCity: 'CADILLAC',
  CalledState: 'QC',
  FromZip: '',
  FromState: 'QC'
}
bobiechen-twilio commented 1 month ago

Hi @devBjn

Thanks for the Call SID. From what I can see, the child that was made by Twilio to the mobile client (ending with UKaZ) failed when Twilio tried to send the push notification to Apple, with the error 52004: Credential Sid is not Specified. Please check if you have put the correct Push Credential SID (CRxxxx) in your Access Token when call the register() method. For more information please check out this: https://www.twilio.com/docs/iam/access-tokens#create-an-access-token-for-voice

devBjn commented 1 month ago

Hi @bobiechen-twilio , I have to add Push Credential SID in my Access Token but it still does not work

{
  "jti": "SKf7aef36bf3ab4613c748cd4c0353800a-1715757247",
  "grants": {
    "identity": "XT1RTlfh6Wax361DUKaZ",
    "voice": {
      "incoming": {
        "allow": true
      },
      "outgoing": {
        "application_sid": "APxxxxxxxx"
      },
      "push_credential_sid": "CRxxxxxxxxxxxx"
    }
  },
  "iat": 1715757247,
  "exp": 1715843647,
  "iss": "SKfxxxx",
  "sub": "ACaxxx"
}
bobiechen-twilio commented 1 month ago

Thanks for the update @devBjn

It seems you did put the Push Credential SID in the access token for the registration, but this time the push notification delivery resulted in a 52143: The push notification was rejected by APNs error, which should also show in your developer console (or email notification). While there are different root causes that could result in this error, I'd suggest checking a few things:

devBjn commented 1 month ago

After creating "VoIP Service" and config again in Twilio with this credential, I can receive an incoming call successfully. Thanks for your help.