Skip to content

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

@whenmoon

Description

@whenmoon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions