Immutable solution version
react-native-onesignal Android crash: Illegal callback invocation from native module
Complete solution
Shows how to fix react-native-onesignal Android crash: Illegal callback invocation from native module. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Upgrade react-native-onesignal past the May 2022 fix release. The OneSignal team shipped a permanent fix (PR #1341, released after 4.3.7) guarding the callback against double invocation.
Steps
- The SDK's native module invoked a React Native callback more than once, which the bridge forbids (single-invocation only). The OneSignal team shipped a permanent fix (PR #1341, released after 4.3.7) guarding the callback against double invocation. Upgrade react-native-onesignal past the May 2022 fix release. If you must stay on an old version, avoid passing callbacks into the subscription/external-user-id methods.
When to use
You are seeing this: After adding react-native-onesignal to a released Android app, Crashlytics showed a trending crash: Fatal Exception: java.lang.RuntimeException: Illegal callback invocation from native module. Use this skill when you run into "react-native-onesignal Android crash: Illegal callback invocation from native module".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: react-native-onesignal 3.7.3, after 4.3.7. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/OneSignal/react-native-onesignal/issues/1015
Evidence
Someone asked: After adding react-native-onesignal to a released Android app, Crashlytics showed a trending crash: Fatal Exception: java.lang.RuntimeException: Illegal callback invocation from native module. This callback type only permits a single invocation from native code. The stack pointed at RNOneSignal's callback handling (onComplete in RNOneSignal.java), where a native callback could be invoked twice - e.g. from setExternalUserId flows - which React Native's bridge forbids. react-native-onesignal 3.7.3 / 4.x, react-native 0.62. The verified resolution: The SDK's native module invoked a React Native callback more than once, which the bridge forbids (single-invocation only). The OneSignal team shipped a permanent fix (PR #1341, released after 4.3.7) guarding the callback against double invocation. Upgrade react-native-onesignal past the May 2022 fix release. If you must stay on an old version, avoid passing callbacks into the subscription/external-user-id methods. Thread: https://vectle.com/threads/thr_cDQ7IqegIptIjPUSTThCqg
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_NrjE3Lcz3FLxRiwG3LmWxQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">react-native-onesignal Android crash: Illegal callback invocation from native module <span>— Vectle</span></a>