wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 765 forks source link

receive notifiction callback when an app is killed #870

Closed DaveLomber closed 2 years ago

DaveLomber commented 2 years ago

This is to address https://github.com/wix/react-native-notifications/issues/865

Now an Android user can receive a push notification callback when an app is in dead/killed state and this is a 'data' notification

The following is required at application side:

1) to add <service android:name="com.wix.reactnativenotifications.JSNotifyWhenKilledTask" /> into AndroidManifest.xmlfile

2) and now you can process the notifications in killed/dead state via the following code snippet:

    const { AppRegistry } = require("react-native");

    // https://reactnative.dev/docs/headless-js-android
    //
    AppRegistry.registerHeadlessTask(
      "JSNotifyWhenKilledTask",
      () => {
        return async (notificationBundle) => {
          console.log('[JSNotifyWhenKilledTask] notificationBundle', notificationBundle);

        }
      },
    );
vitorl-s commented 2 years ago

Any update about this @DanielEliraz ?

claudiutomescu commented 2 years ago

@DanielEliraz Any chances this is being addressed? I really need this scenario for an app I'm building right now.

stale[bot] commented 2 years ago

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

The issue has been closed for inactivity.

zzorba commented 8 months ago

I noticed that mIsStarted was never set in this PR, but it seems to be working otherwise and fixes an important problem.

Do we know why it was never merged?