I'm working on a project using Ionic Framework and Phonegap. I need to use OAuth 2.0 for authentication on my app. When I try to login, the app opens an InAppBrowser window inside the Cordova WebView and loads the consent page. Everything works fine until then.
The problem lies when I close the window and try to open it again, it simply doesn't open! What could it be?
This is in my controllers.js file:
var ref = $window.open(oauthUrl, "_self", "location=yes");
ref.addEventListener("loadstart", function () {
// ...
// do some logic
// ...
ref.close();
$state.go("login");
});
ref.addEventListener("exit", function () {
ref.close();
$state.go("index");
$window.location.reload();
});
I've already tried to remove the ref.close()
lines, put ref.show()
, but none of these work.
don't use _self
, it replaces your content with the oauthUrl content, so cordova.js won't exist and you won't be able to use cordova APIs anymore
use _blank
instead