React-native-notifee: No task registered for key app.notifee.notification-event

Created on 21 Jul 2020  Â·  19Comments  Â·  Source: notifee/react-native-notifee

Hi,

I have all notifications working in iOS and Android, whether app is in foreground, background, or quit. No issues.

For whatever reason, I am getting a warning that states "No task registered for key app.notifee.notification-event"

I am not sure what this means or what the purpose of this warning is, as all functionality is implemented and working correctly. Any help regarding what I can do to silence this warning is greatly appreciated.

All 19 comments

Hi patrick, I am getting issues while the app is in killed state in ios. How to achieve this issue?

Hi, thanks for letting us know. I'll see if I can replicate this locally.

Thanks, Helena.

On Thu, Jul 23, 2020 at 5:22 PM Helena Ford notifications@github.com
wrote:

Hi, thanks for letting us know. I'll see if I can replicate this locally.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/notifee/react-native-notifee/issues/111#issuecomment-662963326,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AP2HDOS3C55IFG7HF3MI7IDR5AP77ANCNFSM4PC25EJA
.

Also getting the same issue with Android. Seems to be triggered by notifications delivered when the app is running in the background.

Also getting this on Android. Following the docs the following generates a notification while the app is closed but does not open the app when tapped. When I manually open the app I receive the warning this issue is about.

 const trigger: TimestampTrigger = {
            type: TriggerType.TIMESTAMP,
            timestamp: time.getTime(),
        }

        // Create a trigger notification
        await notifee.createTriggerNotification(
            {
                id,
                title,
                body: message,
                data,
                android: {
                    channelId: "default",
                    smallIcon: "@drawable/ic_notification",
                    largeIcon: "@mipmap/ic_launcher",
                    color: "#f12317",
                    pressAction: {
                        id: "default",
                    },
                },
            },
            trigger
        )

edit: From the logs it appears that notifee is loading my entire app in the background whenever a notification is delivered. Is that intended? That will definitely mess up my analytics and since the app isn't shown it seems to crash a bunch of things.

Any update @helenaford ?

Hi, we did do a fix for iOS where put in a delay before sending out an event so was wondering if that would have it. But, if it's still happening for both, I'm not sure. I can't seem to replicate, seeing no warning in the logs about events. @mars-lan do you have any log output you can paste?

@AndrewMorsillo the issue with the app not opening when the notification is tapped is a known issue (#121) . Can be fixed by adding 'launchActivity: 'default' inside pressAction.

Think I got to the bottom of this. It happens when notifee.onBackgroundEvent(async ({ type, detail }) => {...} is missing. Please try putting this in your application. There maybe something we can do to check if your app has this or not before sending out an event.

I'm also seeing this message in the console when the app is not running and a local notification is received.

I expected the notifee.onBackgroundEvent to fire, but instead I see this. (Note that I have the async listener function set up as described above).

I want this because I'd like to fire a tracking event when notifications are received. (Note that it works fine when the app is already running in the background). The user experience is good (opening the deeplink works fine), just something is missing with the background event.

@afestein are you seeing it on Android, iOS or both?

Hi,
I am getting this on Android (didn't check it on iOS).
The way I have reproduced it is by setting a firebase background listener and when getting a notification I am trying to set local notification using displayNotification.

messaging().setBackgroundMessageHandler(async remoteMessage => { console.log('Message handled in the background!', remoteMessage.data); await sendNotification(remoteMessage.data); // function that calles notifee.displayNotification });

Seems like the warning message ( "No task registered for key app.notifee.notification-event") is coming right after executing
notifee.displayNotification

@yochidaniel thanks, did you set the notifee.onBackgroundEvent too?

No i didn't and everything is working perfectly without it.
However, I have run another test while setting it on top. So now my index.js looks like:

`messaging().setBackgroundMessageHandler(sendNotification); //send notification is a function that send local notification (see function below)

notifee.onBackgroundEvent(async ({ type, detail }) => {
console.log('got notification');
});

export async function sendNotification(notification){
let message = notification.data;
console.log('send notification using notifee');
let header = message.header;
let subTitle = message.subTitle;
const channelId = await notifee.createChannel({
id: 'default',
name: 'Default Channel',
sound: 'default',
});
notifee.displayNotification({
title: header,
body: subTitle,
android: {
channelId,
pressAction: {
id: 'default',
},
timestamp: Date.now(), // 8 minutes ago
showTimestamp: true,
},
})
.then(resp => {
console.log('sendNotification resp: ',resp)
})
.catch(err => {
console.log('sendNotification error: ',err);
})
}
`

As result, the warning message was not showing anymore. But now I have 2 functions that listen to background notifications.
Also, for some reason, the notification is only vibrating without any sound.

Thanks for the reply @helenaford. This warning is Android-only for me.

On iOS I get nothing at all (no event either). This is a bit off-topic, but I suspect that might be due to missing iOS background event support as mentioned in this comment. See #146

Mmm yeah, think there's another issue for iOS all together. Left a comment on the issue you linked (146) to say it's being looked into.

The current fix on this issue is to set notifee.onBackgroundEvent but don't think it's the permanent fix so will leave this open for now.

I see this as well but don't have a solid reproduction myself, yet.
I've started building a from-scratch demonstrator currently here (it'll move but does exist here now) and I don't have the list of steps that showed the problem but I saw it with this one even so we're close to a repro: https://github.com/mikehardy/rnfbdemo/commit/fc7e943ca95fe1777300985f31db2a075d2da4a5 / https://github.com/mikehardy/rnfbdemo/blob/master/notifee-demo.sh

@mikehardy ah cool. nice script. I have a permanent fix in mind to do what RNFB does which doesn't require the background handler to be set.

Fix is included in the latest release (v0.15.1). Please see release notes here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tautvilas picture tautvilas  Â·  9Comments

ashokkumar88 picture ashokkumar88  Â·  6Comments

beweinreich picture beweinreich  Â·  9Comments

hrishiakhade picture hrishiakhade  Â·  11Comments

hmazer picture hmazer  Â·  4Comments