javascriptprismaonesignal

How do I implement Push notifications to my React application using NextJS?


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?
}

Thank you!

EDIT: I'm OK with a solution without using the OneSignal API preferably.


Solution

  • I guess you are looking for two capabilities of service workers (learn about all available capabilities here):

    1. Periodic Background Sync API
    2. Notifications API

    You can follow these two reference guides by Microsoft:

    1. Use the Periodic Background Sync API to regularly get fresh content
    2. Display notifications in the action center

    Do not confuse yourself between Push API & Notifications API. You are only looking for notification functionality not push.