react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥 [🐛] Bug Report Title - No task registered for key ReactNativeFirebaseMessagingHeadlessTask

Open ricardojmf opened this issue 2 years ago • 27 comments

Issue

I'm currently using Expo v49 with firebase cloud messaging API V1 but can't put background push notifications working on the quitted state for Android.

We have two situations for setBackgroundMessageHandler to trigger on Android:

  • When the app is idle in the background. ✅
  • When the app is quitted. 🚫 .

The first one works properly, but the last one does not work. It gives me this error: No task registered for key ReactNativeFirebaseMessagingHeadlessTask

Can you help me please?


Project Files

Javascript

Click To Expand

_layout.tsx:


// Imports...

messaging().setBackgroundMessageHandler(async (remoteMessage) => {
    displayNotification(remoteMessage);
 });

export default function Root() {
  return (
    <FirstComponentToRender />
  );
}

Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • [ ] iOS
    • [x] Android
    • [ ] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • `@react-native-firebase/messaging version you're using that has this issue:
    • 18.7.3
  • Are you using TypeScript?
    • Yes - 5.1.3


ricardojmf avatar Jan 30 '24 14:01 ricardojmf

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Feb 27 '24 15:02 github-actions[bot]

I am having the same issue on android

ceyanesb avatar Mar 26 '24 23:03 ceyanesb

i have same issue on android

zairigimad avatar May 29 '24 13:05 zairigimad

same

Protonosgit avatar May 30 '24 18:05 Protonosgit

Same

mrcrg avatar Jun 14 '24 08:06 mrcrg

I suspect that this has something to do with expo router and the startup sequence. https://github.com/expo/expo/issues/29757

Is anyone here also using the file based router of expo and has the issue?

Protonosgit avatar Jun 14 '24 21:06 Protonosgit

same problem here. [email protected] [email protected] ├─ @react-native-firebase/[email protected] ├─ @react-native-firebase/[email protected]

function HeadlessCheck
({ isHeadless }) {
    if (isHeadless) {
        // App has been launched in the background by iOS, ignore
        return null;
    }

    // Render the app component on foreground launch
    return <RootLayout />;
}


// Register background handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
    console.log(TAG, 'Message handled in the background!', remoteMessage);
});

registerRootComponent(HeadlessCheck)      
export default HeadlessCheck

Also do not work in Android quited app.

When fcm received: 
//  WARN  No task registered for key ReactNativeFirebaseMessagingHeadlessTask

It would be a big problem for us.

l3815 avatar Jun 17 '24 20:06 l3815

same

pawel565 avatar Jun 23 '24 20:06 pawel565

same

guiathayde avatar Jul 15 '24 17:07 guiathayde

same problem flease fix this

firatbadur avatar Jul 18 '24 17:07 firatbadur

i am facing same issue.

preethisun avatar Aug 01 '24 14:08 preethisun

Has anyone fixed this error?

FernandoAOborges avatar Aug 21 '24 12:08 FernandoAOborges

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

it it still there

ER-AdityaRawat avatar Aug 30 '24 09:08 ER-AdityaRawat

Has anyone fixed this error?

hey you fixed this or not!!

ER-AdityaRawat avatar Aug 30 '24 09:08 ER-AdityaRawat

same

MohamedMegdich1 avatar Aug 30 '24 16:08 MohamedMegdich1

same issue

mitalpatelOG avatar Sep 02 '24 17:09 mitalpatelOG

For me, it only worked this way: only after I placed everything in the root of the app. If you put it inside a hook, you'll get this warning.

FernandoAOborges avatar Sep 02 '24 20:09 FernandoAOborges

For me, it only worked this way: only after I placed everything in the root of the app. If you put it inside a hook, you'll get this warning.

With or without expo file based routing?

Protonosgit avatar Sep 03 '24 10:09 Protonosgit

For me, it only worked this way: only after I placed everything in the root of the app. If you put it inside a hook, you'll get this warning.

With or without expo file based routing?

I've been using React Native for almost 7 years and have never used Expo.

FernandoAOborges avatar Sep 03 '24 11:09 FernandoAOborges

same issue

yossimenash-sf avatar Sep 11 '24 11:09 yossimenash-sf