Pushwoosh / pushwoosh-react-native-plugin

Other
57 stars 43 forks source link

Illegal callback invocation from native module #76

Closed Almouro closed 5 years ago

Almouro commented 5 years ago

Hi guys!

Thanks for writing a RN version for the plugin, it's very helpful!

In production builds on our app, we're getting the infamous:

Illegal callback invocation from native module. This callback type only permits a single invocation from native code. com.facebook.react.bridge.CallbackImpl.invoke

Stacktrace

com.facebook.react.bridge.CallbackImpl.invoke (CallbackImpl.java:28)
com.pushwoosh.reactnativeplugin.PushwooshPlugin$1.process (PushwooshPlugin.java:119)
com.pushwoosh.notification.f.a
com.pushwoosh.notification.g.onReceive
com.pushwoosh.internal.event.EventBus.b
com.pushwoosh.internal.event.EventBus.a
com.pushwoosh.internal.event.c.run

aka this occurs only here on success.invoke

    @ReactMethod
    public void register(final Callback success, final Callback error) {
        Pushwoosh.getInstance().registerForPushNotifications(new com.pushwoosh.function.Callback<String, RegisterForPushNotificationsException>() {
            @Override
            public void process(Result<String, RegisterForPushNotificationsException> result) {
                if (result.isSuccess()) {
                    success.invoke(result.getData());
                } else if (result.getException() != null) {
                    error.invoke(result.getException().getLocalizedMessage());
                }
            }
        });
    }

Calling the register method twice from our app should not trigger such a bug since the success object would be different instances.

That's why I'm thinking it might be coming from Pushwoosh.getInstance().registerForPushNotifications calling the callback twice. Could it be possible? It's a tad hard to debug in the Pushwoosh Android SDK since I can only check decompiled .class files.

Additional details

Devices affected: seems to be all OSes, all brands Occurrences: 866 crashes in last 90 days

This is an issue we seem to have had since we installed the plugin (it was with version 5.11.0 at the time)

wfhm commented 5 years ago

Hi @Almouro,

Checking it.

wfhm commented 5 years ago

@Almouro,

Do you use In-App messages (or this solution) to subscribe for push notifications?

Almouro commented 5 years ago

Hi @wfhm, We use this solution to subscribe for push notifications.

We subscribe with:

DeviceEventEmitter.addListener("pushOpened", (push: PushType) => ...

We only use the functions:

wfhm commented 5 years ago

@Almouro,

Fixed with the latest release.

Almouro commented 5 years ago

@wfhm thanks! Yes https://github.com/Pushwoosh/pushwoosh-react-native-plugin/pull/77/files should fix the issue We'll add in our next release!

Do you know when the callback can trigger twice? It'd be nice to know if there's something we're doing wrong on our end.