cordova 訊息推送,告別,訊息推送伺服器,和 蘋果推送認證,cordova認證

來源:互聯網
上載者:User

cordova 訊息推送,告別,訊息推送伺服器,和 蘋果推送認證,cordova認證

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

 

手機端代碼:

var wsserver = cordova.plugins.wsserver;wsserver.start(1818, {
    // WebSocket Server
    'onStart' : function(addr, port) {
         $.post(“test.ashx”,{Addr:addr,Port:port},function(json){ alert("註冊到伺服器端成功!"); },“josn”);
    },
    'onMessage' : function(conn, msg) {
            cordova.plugins.notification.local.schedule({
                id: 1,
                title: "來自服器(WebSocket 用戶端的訊息)",
                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://' ]
});


後台代碼處理:

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 = "萬惡的蘋果你等著!";
webSocketClient.Send(message);

webSocketClient.close();


我對小編確實無語了,解釋得多,代碼注釋多,就是亂寫一通

想要看詳細解釋

請看QQ日誌:

http://user.qzone.qq.com/273237710/blog/1464765609

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.