[英]How to notify without websocket
I want to integrate a simple notification system in my react application. 我想在我的React应用程序中集成一个简单的通知系统。 I want to notify for example: - new post (when the user post the system need time to transcode the media attached and the publication) - missing settings (the user need to compile some information) - interesting posts etc.. 例如,我想通知:-新帖子(当用户发布系统时,需要时间对附加的媒体和出版物进行转码)-缺少设置(用户需要编辑一些信息)-有趣的帖子等。
There is a simple way to add a websocket, like socket.io, to a reactjs app with an aws lambda backend? 有一种简单的方法可以将websocket(例如socket.io)添加到带有aws lambda后端的reactjs应用程序中?
All the notification not need to be read in real time, maybe an ajax call every 2 minutes can solve my problem, but, in this case, someone can help me avoid ajax call if the app isn't used(like if the app remain opened in a foreground tab...) 不需要实时读取所有通知,也许每2分钟调用一次ajax可以解决我的问题,但是在这种情况下,如果不使用该应用程序,有人可以帮助我避免进行ajax调用(例如,如果该应用程序保留在前景标签中打开...)
componentDidMount() {
this.liveUpdate()
setInterval(this.liveUpdate, 120000);
}
liveUpdate() {
axios.get(endpoint.posts+'/live/', cfg)
.then(res => {
// ...
});
}
This code is in the footer component, the call happen every 120 seconds, but the call will still happen also if a user leave the application opened in the browser and not use it, this on a lambda backend mean a waste of money. 此代码位于页脚组件中,每120秒调用一次,但是如果用户在浏览器中打开应用程序而不使用它,调用仍然会发生,这在lambda后端意味着浪费金钱。
There are 3 main ways of notifying that I can think of at the moment... 目前有3种主要的通知方式可以通知我...
Push (though) requires permission from the user 推送(尽管)需要用户的许可
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.