Cordova message push, farewell, message push server, and Apple push certificate, cordova Certificate
Cordova plugin add org. apache. cordova. vibration
Cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications
Cordova plugin add cordova-plugin-websocket-server
Mobile phone code:
Var wsserver = cordova. plugins. wsserver; wsserver. start (1818 ,{
// WebSocket Server
'Onstart': function (addr, port ){
$. Post ("test. ashx", {Addr: addr, Port: port}, function (json) {alert ("registered on the server is successful! ") ;}," Josn ");
},
'Onmessage': function (conn, msg ){
Cordova. plugins. notification. local. schedule ({
Id: 1,
Title: "messages from the server (WebSocket client )",
Text: msg,
// FirstAt: monday_9_am,
Every: "week ",
// Icon :"",
Data: {meetingId: "123 "}
});
Navigator. notification. vibrate (1000 );
Cordova. plugins. notification. local. on ("click", function (notification ){
Alert (notification. data + ", messageId:" + notification. data. meetingId );
});
},
'Onclose': function (conn, code, reason ){
Console. log ('a user disconnected from % s', conn. remoteAddr );
},
'Origins': ['file: // ']
});
Background code processing:
Var port = this. Request. Params ["Port"];
Var addr = this. Request. Params ["Addr"];
Var webSocketClient = new WebSocket (string. Format ("ws: // {0 }:{ 1}", addr, port ));
WebSocketClient. open ();
String message = "you are waiting! ";
WebSocketClient. Send (message );
WebSocketClient. close ();
:
I am speechless with small series, with a lot of explanations and a lot of code comments.
For more information, see
Please refer to the QQ log:
Http://user.qzone.qq.com/273237710/blog/1464765609