cybex-dev / twilio_voice

Flutter Twilio Voice Plugin
https://twilio-voice-web.web.app/
MIT License
40 stars 86 forks source link

[iOS] Getting NSInvalidArgumentException, data parameter is nil #200

Open soapthepro opened 1 year ago

soapthepro commented 1 year ago

I am trying to use the latest package of twilio_voice on my iPad and iPhone running iOS 17. I have connected the devices to my Mac and trying to run Xcode build in my devices but everytime while executing

TwilioVoice.instance.setTokens(accessToken: '$accessToken')

I am receiving this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' *** First throw call stack: (0x1abfe0870 0x1a434fc00 0x1aaed0830 0x104a93244 0x104a859d8 0x103beae64 0x103bf0704 0x10934ff0c 0x108db4e1c 0x104350f50 0x104352b34 0x104362fec 0x104362ba0 0x1abf2b20c 0x1abf27f18 0x1abf27668 0x1ef2f25ec 0x1ae344294 0x1ae3438d0 0x102068b0c 0x1ce97adcc) libc++abi: terminating due to uncaught exception of type NSException

And the app terminates and the last log available in the console is LOG|pushRegistry:attempting to register with twilio. I am pretty sure that it occurs while setting tokens because if I comment that line, the app works without any termination.

I am not able to figure out what went wrong here as I am able to print the access token and it looks like a valid token to me. Any help will be appreciated!

cybex-dev commented 1 year ago

Hi @soapthepro,

Thanks for reporting this issue. I'll investigate and attempt to replicate on iOS 17.

For now, can you confirm:

soapthepro commented 1 year ago

Hi @cybex-dev,

I was able to figure it out, the problem was that I was storing my access token in sharedPreferences and while setting tokens for some reason it was not passing the token to setTokens function although the token is sound and I am also able to print the token just before the function call and even after adding certain checks and validations I was not able to make it work. Now I am not storing the token in my local storage and directly passing it to setToken function as soon as I receive it from firebase and it works. I am not sure why it is not able to initialise using the stored token. Earlier I was using the old twilio_voice package with my own additions to it and it used to work fine in iOS 16 and iOS 17 using the stored token.