InAppBrowser Events

I am having issues binding to events on the inAppBrowser in my ionic app. So far, my controller looks like this:

angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, Auth, User, $http) {
  $scope.title = "Dashboard";

  var ref = window.open('#/login', '_blank', 'location=no');
  ref.addEventListener('loadstart', function() { console.log(event.url); });
  ref.addEventListener('loadstop', function() { console.log(event.url); });

  Auth.authenticate().then(function(response) {
    console.log('authenticated')
  });
})

.controller('LoginCtrl', function($scope, Auth) {
  console.log('hi');
})

The new window is opened correctly, which has a form like so:

<nav-page title="title">
  <content has-header="true">
    <form method="post" action="http://localhost:3000/user_session">
      <input type="hidden" name="domain" value="fake.com">
      <input type="hidden" name="openid_provider" value="google_apps">
      <button type="submit">Submit</button>
    </form>
  </content>
</nav-page>

Which goes through a standard Google Apps Open ID redirect process and eventually logs in, but inside the child view. I would like to be able to intercept the redirects from this child view and access the params in my main controller.

During the redirect process in the child browser, I would expect the following lines to be creating alerts but nothing happens:

ref.addEventListener('loadstart', function() { console.log(event.url); });
ref.addEventListener('loadstop', function() { console.log(event.url); });

Am I constructing this incorrectly or is this an issue within Cordova possibly?

Any help would be greatly appreciated, Thank You!

Hi Naderhen,

Got the same issue, could not fired the “loadstop” eventListener.

Did you find a fix since your post ?

Thx !

Hey @naderhen and @Stephane, this does indeed seem to be an issue related to that plugin. Unfortunately, I haven’t used it so I’m not exactly sure how to make this work.

Hi @max,

Thanx for your answer, as far I’m concerned I can make it work now and I confirm that Ionicframework is not involved in the issue related before.

S/

@Stephane Any update on this? I’m running into the same issue when launching a window for authentication to a 3rd party like Google or Dropbox.

@Stephane @danbucholtz
Same here, using 3rd party authentication via OmniAuth, I am searching for a smooth way to integrate the login process into my Ionic app…

Any news on this issue? I’m having the same problem.

Commit 8da5e25 of cordova-plugin-inappbrowser fixes loadstart not triggering.
Currently there isn’t a release for this, you can use the master branch to make it work for now.

ionic plugin remove cordova-plugin-inappbrowser
ionic plugin add https://github.com/apache/cordova-plugin-inappbrowser