Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notifee.displayNotification(*) 'notification.id' invalid notification ID, expected a unique string value. #1140

Open
edadma opened this issue Nov 6, 2024 · 2 comments

Comments

@edadma
Copy link

edadma commented Nov 6, 2024

We're seeing

notifee.displayNotification(*) 'notification.id' invalid notification ID, expected a unique string value.

a lot on bugsnag. Has anyone seen this?

Here's the .displayNotification code:

          notificationListener = messaging().onMessage(async (notification) => {
            const channelId = await notifee.createChannel({
              id: 'default',
              name: 'Default Channel',
              importance: AndroidImportance.HIGH,
              description: 'Display notification while in foreground',
            })

            notifee.displayNotification({
              id: notification.messageId,
              title: notification.notification?.title,
              body: notification.notification?.body,
              data: notification.data,
              android: {
                sound: 'default',
                channelId: channelId,
                smallIcon: 'ic_stat_icon_push_notification',
                importance: AndroidImportance.HIGH,
              },
              ios: {
                sound: 'default',
              },
            })
          })
@mikehardy
Copy link
Contributor

Yep, saw it when I did a basic search on repo

https://github.com/search?q=repo%3Ainvertase%2Fnotifee+invalid+notification+ID&type=code

if (objectHasProperty(notification, 'id')) {
if (!isString(notification.id) || !notification.id) {
throw new Error("'notification.id' invalid notification ID, expected a unique string value.");
}

Did you see that when you searched?

isString is doing a typeof

export function isString(value: any): value is string {
return typeof value === 'string';
}

Looks like either your code is sending in a null or something other than a string

What did you see when you console.log the notification information prior to calling the API function that isn't working for you?

@mikehardy
Copy link
Contributor

(worth mentioning you do not include any version information so I'll just assume you are using current versions of...everything? But assumptions are dangerous when requesting or providing support, concrete information + full and complete issue reports always better)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants