- I have a React application using NextJS, deployed on Vercel.
- I want to use OneSignal to send notifications
I have a certain feature in my app called "Reminders", which is just a MySQL table using the Prisma ORM. Here is the table schema:
model Tasks {
id Int @id @default(autoincrement())
name String
note String?
frequency String
on String
lastDone DateTime
property Property? @relation(fields: [propertyId], references: [id])
propertyId String?
}
- I have already set up an API endpoint called
/api/property/tasks
(POST) which returns the current task list- The API requires a token in the body, which is stored via a cookie called
sessionToken
(which never expires) - A variable called
nextDue
is already calculated based on thefrequency
andon
values. (This returns anew Date()
)
- The API requires a token in the body, which is stored via a cookie called
- Using Service Workers and the OneSignal API, how do I make my app send notifications to the user's device when the device's time is equal to
nextDate
, even if the browser tab is closed? - The service worker will need to update to the new data to send the correct push notification in case the task gets deleted or the date gets updated
Thank you!
EDIT: I'm OK with a solution without using the OneSignal API preferably.
from How do I implement Push notifications to my React application using NextJS?
No comments:
Post a Comment