javascript - Phonegap events online/offline not working -


i writing app phonegap(cordova) 3.0.0 , events "online" , "offline" doesn't work. when tried event "resume", event ok. using xcode 4.5 , ios.

this main javascript file of phonegap project:

var app = {      initialize: function() {         this.bindevents();     },     // bind event listeners     //     // bind events required on startup. common events are:     // 'load', 'deviceready', 'offline', , 'online'.     bindevents: function() {         document.addeventlistener('deviceready', this.ondeviceready, false);         document.addeventlistener('online', this.ondeviceonline, false);         document.addeventlistener('resume', this.ondeviceresume, false);     },      ondeviceready: function() {         app.receivedevent('deviceready');     },      ondeviceonline: function() {         app.receivedevent('deviceonline');     },      ondeviceresume: function() {         app.receivedevent('deviceresume');     },      receivedevent: function(id) {         var parentelement = document.getelementbyid(id);         var listeningelement = parentelement.queryselector('.listening');         var receivedelement = parentelement.queryselector('.received');          listeningelement.setattribute('style', 'display:none;');         receivedelement.setattribute('style', 'display:block;');          console.log('received event: ' + id);     } }; 

thank advices

if want display online / offline status need add network-information plugin first command prompt

$ phonegap local plugin add org.apache.cordova.network-information 

after adding plugin online / offline event should work, work fine me


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -