I'm coding an Android app with Angularjs and cordova, but I have a problem: For an oauth call I need to open a new window, go to the withings site and when I come on my callback url close the window.
I have tried to use setInterval (or $interval) to check every 2 seconds if I reveived the infos by a call to my API. It works fine on a computer in chrome but when I compile the app with Cordova I never enter in the loop.
So I tried to catch an event or $watch on the url of my new window but I execute only once my function at the first url change even if my call to the API result an error.
This is my last code but I tried a lot of different tests :
var newWindow = $window.open(result.res);
var unwatch = $scope.$watch(window.location, function() {
$http.get(url)
.success(function(result) {
newWindow.close();
unwatch();
$location.path('/tab/dash');
})
.error(function(error) {
console.log(error);
});
});
If you have any idea to make this work, would be very happy.
Thanks by advance !