Closed abdulragib closed 3 weeks ago
problem solved,small mistake in index.js
fixed add in onBackgroundEvent: // Keep the notification for a bit longer before cancelling setTimeout(async () => { await notifee.cancelNotification(notification.id); console.log('Notification cancelled after delay'); }, 10000); // Delayed cancellation after 10 seconds
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.
i have declare setBackgroundMessageHandler in index.js , at run time , event is trigger in background but onDisplayNotificaitonNotification does not called
messaging().setBackgroundMessageHandler(async remoteMessage => { const data = JSON.parse(remoteMessage.data.message); -->> parsing bcz receiving json in string format console.log('Message handled in the Background mode!', data); requestbatteryOptimizationTurnOff(); onDisplayNotificaiton(data); });
export const onDisplayNotificaiton = async data => { if (Platform.OS === 'ios') { await notifee.requestPermission(); }
const channelId = await notifee.createChannel({ id: 'message_notification', name: 'Notification', visibility: AndroidVisibility.PUBLIC, importance: AndroidImportance.HIGH, sound: 'oxi_tune', });
const notificationId = 'notify';
await notifee.displayNotification({ id: notificationId, title:
${data.senderId.fullname}
, body:${data.content}
, android: { channelId, // Ensure this matches your notification channel ID largeIcon: 'ic_launcher', // Add your icon here sound: 'oxi_tune', // Use default sound or specify custom sound // Recommended to set a category category: AndroidCategory.MESSAGE, visibility: AndroidVisibility.PUBLIC, importance: AndroidImportance.HIGH, fullScreenAction: { id: channelId, }, }, ios: { sound: 'default', foregroundPresentationOptions: { badge: true, sound: true, banner: true, list: true, }, }, }); // Set timeout to hide the notification after a few seconds (e.g., 5 seconds) setTimeout(async () => { await notifee.cancelNotification(notificationId); console.log('Notification cancelled after 7 seconds'); }, 7000); // 5000 ms = 5 seconds };