Hi there,
if you do a native build with Sencha you can listen to the 'onlinechange event'.
With PhoneGap you either ask for the current status or you have to add your own solution.
I have written a few lines to add to 'Ext.device.connection.PhoneGap' and you have the same event being fired.
Code:
Ext.define('Ext.device.connection.PhoneGap', {
extend: 'Ext.device.connection.Abstract',
constructor: function() {
this.callSuper(arguments);
document.addEventListener("online", Ext.bind(this.onConnectionChange, this, [true]), false);
document.addEventListener("offline", Ext.bind(this.onConnectionChange, this, [false]), false);
},
onConnectionChange: function(online) {
this.fireEvent('onlinechange', online);
},
syncOnline: function() {
...
For more detailed information you can exchange the 'online' param for.
this.getOnline(), this.getType()
Add this to app.js launch:
Code:
Ext.device.Connection.on('onlinechange', this.onlineCallback);
onlineCallback: function(online){
// Do your stuff
}