I'm currently working on an app in react native using the expo framework. I'm trying to send a notification from the client that contains a stopwatch in the notification body.
I'm looking to do something like this: stopwatch notification
My problem is that I didn't have much success trying to find the way to update the notification body in expo. I found a different package using react-native called notifee, but I haven't been able to connect it to my project. The error it gave me while trying to import notifee after installing it was- Error: Notifee native module not found. I tried to search how to fix it but I couldn't find a solution.
I wanted to know if there is a way to update notification body in expo, or connect notifee with expo framework. If there isn't, what would you recommend? (e.g. stop using expo and use other framework, or use pure react native etc).
Thanks for any suggestions!
The Code
import * as Notifications from 'expo-notifications';
export default async function NotificationPage(title, minute, second, author, notificationListener) {
await schedulePushNotification(title, author, minute);
}
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
async function schedulePushNotification(title, author, minute) {
await Notifications.scheduleNotificationAsync({
content: {
title,
categoryIdentifier: 'timer_notification',
subtitle: author,
body: 'stopwatch goes here,
data: { data: 'goes here' },
},
trigger: {
seconds: 1,
},
});
}