首页 技术 正文
技术 2022年11月19日
0 收藏 765 点赞 4,278 浏览 1451 个字

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();

效果图:

cordova 消息推送,告别,消息推送服务器,和 苹果推送证书

我对小编确实无语了,解释得多,代码注释多,就是乱写一通

想要看详细解释

请看QQ日志:

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894