HeadlessTasks not working on Android devices, Module AppRegistry is not a registered callable module
See original GitHub issueI am using firebase to push real time config update to my app, receiving real time updates work when the app is in foreground. When the app is in the background i am having 2 errors. We use a detached EXPO application. Expo SDK version : 33
- I am getting a App crash with the following error
java.lang.RuntimeException: Unable to start service io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService@9e4124f with Intent { cmp=com.qliro.qliro.dev/io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService (has extras) }: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3686)
at android.app.ActivityThread.access$1600(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.facebook.react.HeadlessJsTaskService.getReactNativeHost(HeadlessJsTaskService.java:171)
at com.facebook.react.HeadlessJsTaskService.startTask(HeadlessJsTaskService.java:100)
at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:52)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
at android.app.ActivityThread.access$1600(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
if i implement the public class MainApplication extends ExpoApplication implements AppLoaderPackagesProviderInterface<ReactPackage>,ReactApplication
ReactApplication I get the issue 2
2019-07-25 12:10:27.796 7355-7537/com.qliro.qliro.dev W/ReactNativeJS: The "UMNativeModulesProxy" native module is not exported through NativeModules; verify that @unimodules/react-native-adapter's native code is linked properly
2019-07-25 12:10:27.869 7355-7537/com.qliro.qliro.dev W/ReactNativeJS: No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?
2019-07-25 12:10:27.890 7355-7537/com.qliro.qliro.dev E/ReactNativeJS: The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.
2019-07-25 12:10:27.898 7355-7537/com.qliro.qliro.dev E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling startHeadlessTask)```
Android Manifest :
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/>
JS File
// Current main application
AppRegistry.registerComponent('App Name', () => App);
// New task registration
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => bgMessaging);
I tried creating a native headless service and still had the same error. Is there a way to get HeadlessTasks working with expo kit detached ?
Thank you for your help.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Thank you for sharing the code!
This issue has been automatically closed since there has not been any recent activity after it was marked as stale. Please open a new issue for any related bugs.