Skip to content

Headless event listener not called when app is killed #55

Open
@mathiasmoeller

Description

@mathiasmoeller

Hey @eddieowens !

When the app is in foreground or background the boundary callbacks work perfectly!
But I am struggling with the Headless part when the app is killed.
In logcat I can see that the event is fired. I see the log message from boundary's index.js file:

ReactNativeJS: 'onExit', [ 'rated0' ]

which comes from this part of code here:

const HeadlessBoundaryEventTask = async ({event, ids}) => {
  console.log(event, ids);
  boundaryEventEmitter.emit(event, ids)
};

But my callback is never executed. I think the issue might be timing.
When the app starts because of a Headless event I can see that boundary receives the event as said above. I added log messages for the Callback Registration and it seems to happen after the Headless event:

15:03:19.837 ReactNativeJS: 'onExit', [ 'rated0' ] // from boundary's index.js
15:03:19.863 ReactNativeJS: Registering Boundary Callbacks // my code

I moved the callback registration to the very first line of my index.js but the order still seems to be incorrect. Any idea how to solve this? Where should I call the Boundary.on callback registration in my code?

Setup:

  • "react-native": "0.59.5"
  • "react-native-activity-recognition": "woffu/react-native-boundary" // fix for newer android versions

Help is very much appreciated :)

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