Instabug-React-Native icon indicating copy to clipboard operation
Instabug-React-Native copied to clipboard

Fix Android initialization with no invocation events

Open romanbb opened this issue 4 years ago • 2 comments

Null check the array before accessing it.

romanbb avatar Jul 01 '20 22:07 romanbb

Hi @romanbb, thank you for submitting a PR!

Would you mind sharing the use case where the invocation events need to be passed as null? What is it you want to achieve but can't with the current implementation?

AliAbdelfattah avatar Jul 01 '20 23:07 AliAbdelfattah

Hi @romanbb, thank you for submitting a PR!

Would you mind sharing the use case where the invocation events need to be passed as null? What is it you want to achieve but can't with the current implementation?

Hey @AliAbdelfattah - sure!

Our use case was that we are including the Instabug library via the RN package. We did not want to load the library for development builds. So we simply omitted the following call when it was a development build:

Instabug.startWithToken(<>, [Instabug.invocationEvent.shake])

And this produced the crash. A third party library shouldn't be causing a crash if not invoked I think. Perhaps a warning, or a more useful exception can be thrown if you feel strongly about the usage of the API and requiring a startWithTokenCall().

romanbb avatar Jul 02 '20 21:07 romanbb

Thanks @romanbb for this PR! But since v11, the SDK can now be initialized from JS only, you do not need handle this from your Java code anymore.

Here's what you can do for now:

  1. Check out v11 migration guide and move your code to JS.
  2. Consider using Instabug.invocationEvent.none instead of null or an empty array.

TheBuggedYRN avatar Sep 08 '22 14:09 TheBuggedYRN