Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invokeApp is not called when app is in background, DeviceEventEmitter is only called upon opening app when app is killed #8

Open
whenmoon opened this issue Nov 2, 2019 · 3 comments

Comments

@whenmoon
Copy link

whenmoon commented Nov 2, 2019

I am receiving data only Firebase Cloud Messages when my Android React Native app is in the background or is killed. Here is my headless task:

AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => backgroundMessaging);

Inside my backgroundMessaging function I have this code:

const backgroundMessaging = async (message) => {
  // handle your message
  console.log(message);
  const log = { logMessage: 'this is the event emitter log' }
  invokeApp({ data: log });
  return Promise.resolve();
}
export default backgroundMessaging;

When the app is in the background the above function logs the message, but invokeApp does not seem to be called because the DeviceEventEmitter does not log anything:

    DeviceEventEmitter.addListener('appInvoked', (data) => {
      const { logMessage } = data;
      console.log(logMessage)
    });

However, when the app is killed (not in background), once I open the app the DeviceEventEmitter function logs the logMessage.

At no point does the app come to the foreground.

@whenmoon
Copy link
Author

whenmoon commented Nov 3, 2019

I have figured out that my issue is actually the same issue as this one.

@Alarees
Copy link

Alarees commented Dec 26, 2019

hi
if you are using react native firebase v >6, as they say:

This method must be called outside of your application lifecycle, e.g. alongside your AppRegistry.registerComponent() method call at the the entry point of your application code.

setBackgroundMessageHandler
i use it and it work's fine
but the the app open's and NativeEventEmitter is not working
PS : DeviceEventEmitter is deprecated as in stackoverflow Question
if you have another idea please share it

@vmehar13
Copy link

IMG_20230725_171146.jpg

You need to be "Allowed" "Display over other apps" from "App Info" manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants