61
Views
14
Comments
[InAppBrowser Plugin] Retrieving the URL that the page that is currently in InAppBrowser
inappbrowser-plugin
Mobile icon
Forge asset by OutSystems
Application Type
Mobile
Service Studio Version
11.55.7 (Build 63962)
Platform Version
11.25.0 (Build 41743)

Will it be possible to retrieve the URL that the InAppBrowser is currently showing? Or have a callback to to get the url?

2022-07-24 08-50-37
Gokula Kannan P

Hello @Jeremy Kuang ,

You can't achieve this directly, but by customizing the plugin, you can add your own logic and additional operations to capture the URL.

example:

var ref = cordova.InAppBrowser.open('https://example.com', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) {
    console.log("New URL: " + event.url);
});

2022-08-26 05-45-19
Jeremy Kuang

Was the previous version of OutSystems' implementation of the InAppBrowser plugin and import from Cordova's? If it is, then maybe this will work for the previous version. But it seems that the latest version is a an implementation by OutSystems themselves.

2022-08-26 05-45-19
Jeremy Kuang

Are you suggesting to use InAppEventBrowserEvents plugin? Correct me if I am wrong, but I believe InAppBrowserEvents does not support the latest version of the InAppBrowser plugin. Or at least, I have tried and it is not supported. Please let me know if you have tried and it is working for you (=

UserImage.jpg
Stanislav Ploschansky

Hi,

I have the same pain.

We have to patch plugin to support this. Have no idea why OS published this plugin without such built-in functionality.

I'll work on this now.

Stan


UserImage.jpg
Sabeeb Anengadan

Looking for the same functionality what InAppEventBrowserEvents  provides.


Unfortunately the official Plugin (InAppBrowser) doesn't have the minimum capability to address requirements

UserImage.jpg
Stanislav Ploschansky

InAppBrowserEvents not compatible with latest InAppBrowser plugin

UserImage.jpg
Sabeeb Anengadan

Yes , But its required to have the event call back features to track the in App browser navigations especially for the OIDC/Oauth2 flow for mobile application. MABS version 11 required to have latest plugin update.

Please refer
https://www.outsystems.com/forums/discussion/99096/inappbrowserevents-update-component/

UserImage.jpg
Stanislav Ploschansky

Yes, there are 2 threads about same problem. 
I was trying td patch plugin but it will require deeper diving than I expected.
And having MABS 10 depreciated soon is a serious problem indeed.  


2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello @Jeremy Kuang 

Use the below JS code to get the Current URL of the page instead of calling the open action, use this JS code.

  1. cordova.InAppBrowser.open ("https://example.com", "", "");
  2. cordova.InAppBrowser.Events.LoadStart = function(event) {
  3.     console.log("Current URL: " + event.url);
  4. };

inside the LoadStart event function, you can do what you want, like call another client action with the URL input parameter that does the work you want to do .


UserImage.jpg
Stanislav Ploschansky

@Gourav Shrivastava it works with prev version of InAppBrowser.
The latest version of InAppBrowser  plugin has fully different implementation and doesn't return browser object. You can see that in source of plugin.


2024-07-12 05-57-50
Gourav Shrivastava
Champion

Yes @Stanislav Ploschansky  ,

@Jeremy Kuang  in this case, please use this code for getting URL 

  1. var ref = cordova.InAppBrowser.open('https://example.com', '_blank', 'location=yes');
  2. ref.addEventListener('loadstop', function() {

        ref.executeScript(

            { code: 'window.location.href;' },

            function(values) {

                var currentUrl = values[0];

                console.log('Current URL:', currentUrl);

                // You can now use the currentUrl variable as needed

            }

        );

    });


If you need reference, you can also check out this Documentation.

Thanks 

Regards Gourav




UserImage.jpg
Stanislav Ploschansky

@Gourav Shrivastava , your comments related to PREVIOUS version of plugin which available via

> cordova.InAppBrowser. 

The new version of plugin uses https://github.com/OutSystems/cordova-outsystems-inappbrowser and there plugin injected differently and implemented FULLY DIFFERENTLY

> cordova.plugins.OSInAppBrowser

Look for example here https://github.com/OutSystems/cordova-outsystems-inappbrowser/blob/main/src/www/web.ts and you will see Open* functions doesn't return browser object like previous version of plugin.

2024-07-12 05-57-50
Gourav Shrivastava
Champion

Thanks for clearing me, I got your point, let me check the changes in this component and if I got something, I will let you know.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.