即时通讯使用MetoerRider方法,本质上是phonegap应用程序启动,一旦应用程序完成启动它就会对流星应用程序执行ajax调用(“ http://myapp.meteor.com”)
我得到了流星应用程序的DOM作为回应.
$.ajax({ url: __MeteorRiderConfig__.meteorUrl,cache: false,// Todo: split to method on MeteorRider error: function( jqXHR,textStatus,errorThrown ) { console.error("MeteorRider failure"); console.error(jqXHR,errorThrown); },// Todo: split to method on MeteorRider success: function( data,jqXHR ) { console.log("MeteorRider success"); console.log(textStatus); console.log(data); // update URLs data = data.replace(/(href|src|manifest)\=\"\//gm,'$1="' + meteorUrl + '/'); console.log(meteorUrl); console.log(data); // get the original file location,not including any params phonegapLocation = window.location.href.split('.html')[0] + '.html'; // it's stored in a param "page" currentMeteorPath = window.location.search.replace("?","") if(currentMeteorPath.length > 0) { meteorUrl += currentMeteorPath.split('page=')[1] } console.log("replacing state with "+meteorUrl) window.history.replaceState({},"",meteorUrl); // replace the document with the new document/data document.open(); document.write(data); document.close(); // trigger the "loaded" events (it'd be nice to do this AFTER JS has loaded $(document).trigger('DOMContentLoaded'); $(document).trigger('load'); $(document).trigger('complete'); } }); }
问题是我的phonegap应用程序只在wifi打开时工作,一旦我关闭wifi它停止工作,如果我启动我的phonegap应用程序当wifi关闭我仍然得到流星DOM到我的phonegap应用程序,但我不能做任何功能(登录/创建组等).
所以我开始调试我的应用程序(使用build.phonegap.com中的phonegap调试),
这是我打开wifi时得到的日志:
if(navigator.onLine){ console.log("true") } else{ console.log("false") }
日志 – > “真正”
var networkState = navigator.connection.type; var states = {}; states[Connection.UNKNowN] = 'UnkNown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.NONE] = 'No network connection'; console.log('Connection type: ' + states[networkState]); }
日志 – > ‘WiFi连接’
Meteor.status()
日志 – >连接:是的
retryCount:0
状态:“已连接”
使用移动网络时:
if(navigator.onLine){ console.log("true") } else{ console.log("false") }
日志 – > “真正”
var networkState = navigator.connection.type; var states = {}; states[Connection.UNKNowN] = 'UnkNown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.NONE] = 'No network connection'; console.log('Connection type: ' + states[networkState]); }
日志 – > ‘Cell 3G连接’
Meteor.status()
日志 – >连接:错误
retryCount:1
状态:“连接”
试图做Meteor.reconnect()没有帮助,它没有工作.
当打开wifi时,当进行Meteor.disconnect()时,应用程序会断开连接,但是当尝试执行Meteor.reconnect()时,它也无法正常工作.
当切换(当应用程序工作时)要么wifi上/ wifi关闭.我失去了所有连接,甚至无法调试.
编辑:添加了离线活动
phonegapapp = { // are we on a phonegap app? phonegap: true,// are we testing PhoneGap or not? test: false,// Application Constructor initialize: function () { this.bindEvents(); },// Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load','deviceready','offline',and 'online'. bindEvents: function () { document.addEventListener('deviceready',this.onDeviceReady,false); },// deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function,we must explicity call 'phonegapapp.receivedEvent(...);' onDeviceReady: function () { document.addEventListener("offline",this.onOffline,false); phonegapapp.receivedEvent('deviceready'); phonegapapp.receivedEvent('offline'); if (this.test) { $('phonegapapp-test').show(); } else { phonegapapp.meteorRider(); } },// Update DOM on a Received Event receivedEvent: function (id) { console.log('Received Event: ' + id); },onOffline: function () { device.exitApp(); },// Setup MeteorRider meteorRider: function () { MeteorRider.init(); } };
更新:
在另外一个流星应用程序(没有铁路由器,test.meteor.com)上测试了两部Android手机(v 4.1.2和v 4.3.3).记录两部手机 – Meteor.status()在使用移动网络时“连接”.但是当打开/关闭wifi时,两者都丢失了任何网络连接.
所以我把它缩小到两个可能的问题:
1.my meteor app做错了什么.
2.iron路由器
另一个检查另一个流星应用程序(使用铁路由器的应用程序)
meteor.status()记录“已连接”.
我相信失败的原因是在我的应用程序中,我不会在我的流星应用程序中看到任何错误.
新更新:
好吧所以这真的很奇怪,我已经开始了一个新的流星应用程序只是做“流星创建测试”
添加了铁路由器和更多的软件包,如下划线jquery帐户等.
然后我把它部署到流星 – 流星部署boaz.meteor,com
提示输入密码,选择我的phonegap应用程序查看其工作是否记录为Meteor.status();并得到“虚假”和“连接”
新更新:
尝试创建一个没有任何更改的应用程序或没有添加任何包或删除任何包.
也许,Meteor.status();记录“假”和“连接”
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。