Illegal callback invocation from native module

Hi there,

On using Notifications.getDevicePushTokenAsync() - I’m getting the below error

Getting Illegal callback invocation from native module. This callback type only permits a single invocation from native code

Can anyone let me know why I can’t use this function?

Hey - just incase anyone comes up against this

On Android, the condition to test if the app was running as a standalone or not, was not working, so the native code was trying to run on the emulator. PN will not work on anything but the standalone app.

In iOS it was fine, a warning would appear when trying to use this function.

Not sure why the isShellApp condition was returning true for me - but might help someone else.

Best
David

Not sure I understand what’s going on here. You built a standalone apk and then installed it on an emulator?

Hey @jesse

Using Genymotion and the Expo app on my phone resulted in the below error when using Notifications.getDevicePushTokenAsync() on Android only. It traced to line 84 on NotificationsModule.java

Illegal callback invocation from native module error

On iOS when using an emulator, the expected outcome - a warning that the function is only accessible in a standalone application appears.

On an standalone APK - the function works as expected, and returns a GCM token. That’s the main thing so thank you for recently making this available.

I can see the condition in NotificationsModule.java that check’s if it’s a device or not - but at least for me, the condition wasn’t catching in the emulator and crashing the app.

Within React Native Constants.isDevice works as expected, so I’m just checking within my app before I ask for the token.