Cordova message push, farewell, message push server, and Apple push certificate, cordova Certificate

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.