onPause is not working with http request?

I’ve set my “pause” callback function with http request using angular service but it seems like it does not request http…, is this wrong way to use it?

function onDeviceReady(){
    	$ionicPlatform.on("pause", onPause);

   function onPause() {
    		SessionSvc.updateOnlinestat(false, $scope.guid)
    			console.log("session current online stat:", session.onlinestat);

First, is the event fired?
Secondly, are your trying on iOS or Android? Cause in iOS, as soon as an app is paused, the app execution stops immediately, meaning nothing in pause works until the app is resumed. Only the smallest of tasks like, setting a variable, seem to work on pause. Something as elaborate as sending an http request will not work. and even if it does, it will not work consistently.


Yes its fired and yes, console.log seems to work but http actually send the req when its resumed…

I really need to send http request as it goes to background or turning off app/device.

How should i do it?

Unfortunately, there is no solution to this problem as of now…:/… iOS just works that way, the best solution would be to show some spinner when the app resumes, so that you can do what you want to do and the user does not interfere.

would it be possible to use any of html/js event like “beforeunload” or something? I really need to get the http request working when “pause” or go background…

I am also facing the same problem. Any luck on this?