Open nbobic1 opened 1 year ago
Share code please
Hi,
Same here got the error on XCode : [native] JSON value '{ }' of type NSMutableDictionary cannot be converted to a date
With the example provided :
Notifications.postLocalNotification({ body: 'Local notification!', title: 'Local Notification Title', sound: 'chime.aiff', category: 'SOME_CATEGORY', fireDate: new Date(), })
Also types are wrong as shown:
Getting the same error for the wrong types - few of them does not exist (fireDate, category, etc) and some more are required. Anyone know what is happening? And if the fireDate is no longer present, how can you schedule a notification?
Same issue here... types are wrong and method has no effect. Is this package maintained?
Hi,
After couple of non working code with this library, I switched to @notifee/react-native
I use it to present firebase notification when app is open and in foreground, like Messenger do for example:
...
// Resend notification for local display (RNFirebase don't do so)
if (when === When.front && 'notification' in message) {
// Create a channel (required for Android)
const channelId = await notifee.createChannel({
id: 'default',
name: 'main channel',
})
// Display a notification
await notifee.displayNotification({
title: message.notification?.title,
body: message.notification?.body,
data: message.data,
android: {
channelId,
localOnly: true,
pressAction: {
id: 'default',
},
},
})
}
...
Hope it helps, BR
Hi,
After couple of non working code with this library, I switched to
@notifee/react-native
I use it to present firebase notification when app is open and in foreground, like Messenger do for example:
... // Resend notification for local display (RNFirebase don't do so) if (when === When.front && 'notification' in message) { // Create a channel (required for Android) const channelId = await notifee.createChannel({ id: 'default', name: 'main channel', }) // Display a notification await notifee.displayNotification({ title: message.notification?.title, body: message.notification?.body, data: message.data, android: { channelId, localOnly: true, pressAction: { id: 'default', }, }, }) } ...
Hope it helps, BR
I switched to notifee as well. Very simple to setup, no native setup required, works like a charm.
The issue with Notifee is that it doesn't fire an event when the app is in background and the notification is presented... I need to catch silent (data-only) notifications.
The issue with Notifee is that it doesn't fire an event when the app is in background and the notification is presented... I need to catch silent (data-only) notifications.
What do you mean? It fires notifications when the app is in background, or even killed.
@Vpvladimirov it doesn't fire an event when the notification is displayed, like it does for foreground notifications. I need this with silent notifications to run some background action.
same problem + 1
Here is how I solved it on iOS.
interface NotificationMessageType<T> {
title: string
body: string
userInfo?: T
sound?: string
silent?: string
category?: string
fireDate?: string
}
const postLocalNotification = <T>(notification: NotificationMessageType<T>, notificationId?: number)=> {
return Notifications.postLocalNotification(notification as unknown as Notification, notificationId)
}
postLocalNotification({ title: 'hello', body: 'world', fireDate: new Date().toISOString() })
on Android, open notification happed wrong.
2023-09-19 16:44:50.670 1616-2770 ActivityTaskManager system_server E START {flg=0x10200000 hwFlg=0x10 cmp=com.chen.test/.MainActivity (has extras)} result: 3
Switching to @notifee/react-native as well. Works flawlessly so far and their API appears to be more well-designed!
I tryed to implement this to show notification from my app, but it doesn't do anything. postLocalNotification returns id but doesn't show notification. I tryed running example, still no notifications showing. React Native implementation. Am I missing some part of implementation?