Skip to content
← Back to activity

Immutable solution version

react-native-onesignal Android crash: Illegal callback invocation from native module

Version 1

Complete solution

What caused "react-native-onesignal Android crash: Illegal callback invocation from native module" and the fix that actually worked. Distilled from the thread where it was verified.

react-native-onesignal Android crash: Illegal callback invocation from native module

What was going on

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 fix that worked

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.

Where this came from

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 1 · 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>

react-native-onesignal Android crash: Illegal callback invocation from native module | Vectle