Search code examples
sqliteionic-frameworkpush-notificationionic3ionic-storage

What is the best practice to store push notifications? IONIC 3


I’m new on Ionic and I’m developing an app that has a notification page. The user will receive push notifications and the app must store all push notifications that it has been received. The app will also show a list of all read/unread notifications and change the status when the user reads the message.

I’m thinking to use the SQLite plugin and create methods to select an specific notification, all notifications, and an alter method to change the status read/unread.

Am I on the right way or there is a best practice to do it?


Solution

  • No, I don't think a local SQLite plugin can help you (assuming you send the notifications to the user remotely, i.e., from a server.)

    Your app may not even be running when a notification is received, and the user may not even open the app upon receiving a notification. Therefore, you won't have a chance to store these notifications, and they will be lost.

    The right way to do this is to have a remote database on your server. When you send a notification, you should also store the notification for that user in the database. Whenever the user opens the app, you should request for the notification table for each user, and mark the one that he/she sees as seen.

    You can use Firebase database for this, which is very easy to code for.