Project needs to push the message, but also want to lower development costs, specific requirements: role users in the background Management page to publish a message, all users of this system on any page can receive his message in a timely manner, and then I on the internet to find a third party free push service-goeasy push, It can meet my needs, below is how to use goeasy for information push and receive:
The first type: Java server-side push, web-side receive push information
Steps:
从GoEasy官网下载jar包,并放到项目中。
Https://cdn.goeasy.io/sdk/goeasy-0.1.jar
- Java code comes, you do not read wrong, only two lines of code:
Goeasy goeasy = Goeasy ("Your App key");
Goeasy.publish ("Your_channel", "your Message");
How do I get appkey?
Register and activate your account on the Goeasy website, then you can log in to the backend system to add application yourself, after adding application, the system will automatically help you generate Appkey, and then you can use.
The push is complete, and here's how to receive the push message.
Introduction of Goeasy.js
<script type= "Text/javascript" src= "Https://cdn.goeasy.io/goeasy.js" ></script>
Initializing the Goeasy object
<script type= "Text/javascript" >
var goeasy = new Goeasy ({
Appkey: ' Your app key here '
});
</script>
5.JS Subscribe to Channel
Goeasy.subscribe ({
Channel: ' Your_channel ',
Onmessage:function (message) {//auto receive push message
Alert (' Meessage received: ' +message.content);
}
});
It is important to note that only when the channel of the subscription is consistent with the channel of the push will it be received correctly! (the principle is similar to the frequency of radio!) )
The implementation is complete!
The second type: Web-side push, web-side receive push information
Steps:
Introduction of Goeasy.js
<script type= "Text/javascript" src= "Https://cdn.goeasy.io/goeasy.js" ></script>
Initializing the Goeasy object
<script type= "Text/javascript" >
var goeasy = new Goeasy ({
Appkey: ' Your app key here '
});
</script>
JS Push message:
Goeasy.publish ({
Channel: ' Your_channel ',
Message: ' Hello world! ' The information you want to push
});
JS subscription information
Goeasy.subscribe ({
Channel: ' Your_channel ',
Onmessage:function (message) {//auto receive push message
Alert (' Meessage received: ' +message.content);
}
});
The code is very simple and does not require a variety of configurations!
Goeasy Official website: Https://goeasy.io
Quick Start: https://goeasy.io/www/started.jsp
Document: https://goeasy.io/www/docs.jsp
Java message push------goeasy for server-side push and web-side push