I am completing the development of a mobile application (ionic but non-essential) supported by a backend developed in Ruby on Rails 5 that is irrelevant, as this is more of a theoretical question / problem.
The point here is that users in the mobile application can log in or not (they have a bunch of functionality, and perhaps half of them can be accessed if you do not log in), how should I handle the storage of the notification itself and the status reading? Note: with a notification, I do not mean a push notification, but for a "message" that remains in the side menu inside the application (I have current delivery enabled).
The main problem is this: I want to be able to track read notifications so that they are not marked as unread if the user reinstalls the application (submit 50 unread notifications just because you reinstalled).
I started with the model as follows to store notifications in the backend:
- ID
- user_id
- push_notification_id (link to the push notification identifier is not relevant)
- : Boolean
- content: Text
With this model, I would insert a row for each user that should be notified, and track with a boolean column whether it was read or not. The problem is that only registered users can receive notifications.
The second option is to delete the user_id link and the read attribute on the server, and suppose that I will always notify all, not some users. But now I need a way to keep track of which notifications have been read. I could do this locally in a mobile application, storing some identifiers in local storage, but then they will be deleted in case of reinstallation.
The third option that I was thinking about is to implement the second option with the "expiry" server server, which indicates when the notification ceases to be "unread" by default when a new application is installed. This is the best I've received so far, but I'm not sure.
I know that I ask a lot of things here, but I'm just looking for a good implementation model that someone has done before, since I could not find anything in the search engines, and I am sure that this is a very repetitive design.
Thanks!