Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230763

Ask InAppBrowser to always use _blank

$
0
0

Sure! I only call the oidc signing popup. I just forked the repo to check if it was using _blank by default and it seems to be using _blank.

  public startAuthentication() {
    if (this.app.isApp()) {
     this.manager.signinPopup().then((user) => {
       this.setUserInfo(user);
     }).catch((e) => {
       console.log(e);
     });
    } else {
      return this.manager.signinRedirect();
    }
  }

After reading through the source of the OIDC-client plugin I found the following:

const DefaultPopupFeatures = 'location=no,toolbar=no,zoom=no';
const DefaultPopupTarget = "_blank";

export class CordovaPopupWindow {

    constructor(params) {
        this._promise = new Promise((resolve, reject) => {
            this._resolve = resolve;
            this._reject = reject;
        });

        this.features = params.popupWindowFeatures || DefaultPopupFeatures;
        this.target = params.popupWindowTarget || DefaultPopupTarget;
        
        this.redirect_uri = params.startUrl;
        Log.debug("CordovaPopupWindow.ctor: redirect_uri: " + this.redirect_uri);
    }

    _isInAppBrowserInstalled(cordovaMetadata) {
        return ["cordova-plugin-inappbrowser", "cordova-plugin-inappbrowser.inappbrowser", "org.apache.cordova.inappbrowser"].some(function (name) {
            return cordovaMetadata.hasOwnProperty(name)
        })
    }
        navigate(params) {
        if (!params || !params.url) {
            this._error("No url provided");
        } else {
            if (!window.cordova) {
                return this._error("cordova is undefined")
            }
            
            var cordovaMetadata = window.cordova.require("cordova/plugin_list").metadata;
            if (this._isInAppBrowserInstalled(cordovaMetadata) === false) {
                return this._error("InAppBrowser plugin not found")
            }
            this._popup = cordova.InAppBrowser.open(params.url, this.target, this.features);
            if (this._popup) {
                Log.debug("CordovaPopupWindow.navigate: popup successfully created");
                
                this._exitCallbackEvent = this._exitCallback.bind(this); 
                this._loadStartCallbackEvent = this._loadStartCallback.bind(this);
                
                this._popup.addEventListener("exit", this._exitCallbackEvent, false);
                this._popup.addEventListener("loadstart", this._loadStartCallbackEvent, false);
            } else {
                this._error("Error opening popup window");
            }
        }
        return this.promise;
    }

The popup target is set in the UserManagerSettings, but I was not providing an option to specify the target. I just tried to explicitly set it to _blank, but I do not think it will change anything


Viewing all articles
Browse latest Browse all 230763

Trending Articles