In a message notification system, there are comment notifications, reply notifications, and so on:
- 每种通知在web前台显示格式是不一样的; - 对于同一种通知如评论,根据其所评论的内容在web前台显示时又是不一样的,如评论了日记与评论了照片在消息通知的显示中是不一样的; - 另外,一张照片的评论也可能会有好几种显示格式;
Considering the extensibility, I also can not be displayed to the content of the notification hard to write to the database or Redis, see the online reference to the "template", if the simple invocation of its display template based on the notification type, I do not think, but I do not know how to design a database to achieve my above requirements, Do not know how people design such a similar message notification?
Reply content:
In a message notification system, there are comment notifications, reply notifications, and so on:
- 每种通知在web前台显示格式是不一样的; - 对于同一种通知如评论,根据其所评论的内容在web前台显示时又是不一样的,如评论了日记与评论了照片在消息通知的显示中是不一样的; - 另外,一张照片的评论也可能会有好几种显示格式;
Considering the extensibility, I also can not be displayed to the content of the notification hard to write to the database or Redis, see the online reference to the "template", if the simple invocation of its display template based on the notification type, I do not think, but I do not know how to design a database to achieve my above requirements, Do not know how people design such a similar message notification?
A solution:
Notifications do not carry specific content or carry the minimum amount of necessary information (such as 消息数 , and 发送方 so on), when the user actually clicks on the asynchronous access to the specific message content.
Take the Android push as an example. This for my factory first product of an implementation. The delivery notification type, along with the user ID, is then pushed to the notification hub after the resolution is complete. Similar to the above, carry the minimum amount of necessary information, and then asynchronously get the specific rendering content.
Say how the specific notification information is presented.
First, the information stored in the store is not necessarily the information that is ultimately presented to the user. The information presented to the user should be assembled at the service level or on the page. Store or save basic data information, such as specific comment content, time, image link, etc.
Late last night, the train of thought is not very clear. Now let's Add.
The method mentioned above is one. There is also the view layer (web, app) contract the specific message format, and then service complete the message assembly at the layer.
Take iOS push as an example: iOS push because it is to comply with Apple's APNS protocol, alter is Alter,badge is badge, need to pass to the app, then encapsulated in custom. The web can also be similar, contract a specific notification format, and then judge and present it at the Web layer.
That's what I'm currently doing, and now to push the message to the user,
This information is divided into a variety of, if you use Redis to store it? And how to read the message record that the user has not read??