I am encoding an Android application with Angularjs and cordova, but I have a problem: To call oauth I need to open a new window, go to the links site and when I am on my callback, close the window.
I tried to use setInterval (or $ interval) to check every 2 seconds if I found information on calling my API. It works fine on a computer in chrome, but when I compile an application with Cordova, I never go into a loop.
So, I tried to catch an event or $ watch in the url of my new window, but I execute only once when my function changes the URL for the first time, even if my API call leads to an error.
This is my last code, but I have tried many 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 an idea to do this work, I will be very glad.
Thanks in advance!
source share