Skip to content

Instantly share code, notes, and snippets.

@calendee
Created November 3, 2017 15:09
Show Gist options
  • Save calendee/5a3ef001f29174c12df48cd3cffc8b06 to your computer and use it in GitHub Desktop.
Save calendee/5a3ef001f29174c12df48cd3cffc8b06 to your computer and use it in GitHub Desktop.
Forcing App to Change Network Status
var app = document.getElementsByTagName('body');
var scope = angular.element(app[0]).scope();
var rootScope = scope.$root
// Make app think you're offline
scope.$apply( function() {
rootScope.$broadcast('$cordovaNetwork:offline');
});
// Make app think you're online
scope.$apply( function() {
rootScope.$broadcast('$cordovaNetwork:online');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment