Unable to get URI scheme from WebView after redirects

Hello! I’m trying to integrate MobilePay in to my Fuse app. The process is handled inside a WebView and it works ok on iOS. Homewer on Android the process stops after MobilePay redirects the WebView to a Uri scheme to launch MobilePay app. At this point the WebView just says “page not available” / “page at address mobilepaypos://online…” etc. My plan was to intercept the URI scheme by using UrlChanged and then use InterApp.launchUri to treat the Uri accordingly, but the Uri is not updated to the WebView’s URL. Where can I get the Uri to pass it to launchUri? The Uri can be seen in the WebView’s error page only.

A very important issue.
UrlChanged in WebView can not get url unless page is moved normally.
Therefore, we Can not get custom schema information.
There must be a solution.

I added a custom schema to the site that can be moved to a temporary solution.

Example) https://www.google.com/?schema=sss://woeijfowiejfoij

removed https://www.google.com/?schema= and used interApp.

Unfortunately I can’t use this temporary solution because the backend is controlled by MobilePay and I don’t think they are open to fixes regarding this issue. One solution is to monitor the ProgressChanged and read the HTML source in JS (because the URI can be stripped from the source), but I don’t know if there’s a method to get the HTML source of a WebView in any given time…?

You can’t read dynamic custom schema…
If you abandon the design and use interApp or InAppBrowserTab, the function implementation is possible.

My problem is that MobilePay process starts off with POST variables submitted to a URL which at some point turns into a URI scheme. One solution could be to create a server side session. In Fuse app we get an URL from the server with a session token and we open this InterApp, so the device’s own browser deals with the upcoming URI scheme accordingly. Though we have to find a way to return back to the Fuse app after the payment is processed, but maybe this could be done with a URI scheme also.

IOS recommends SafariViewController in https://github.com/fusetools/FuseCloud more than interApp.

In my case with MobilePay the problem occurs only on Android. MobilePay doesn’t make any URI redirects on iOS. I heard that this could be fixed with modifying the shouldOverrideUrlLoading method, but i’m not yet familiar with Foreign Code and Java.

I included a screenshot which describes my problem the best. The URI “mobilepaypos://…” can not be read by creating an observable of the Url of WebView because it’s value is the URL of the previous page before being redirected to the URI to open MobilePay app. How can I get this URI?

Found a really dirty way to make it work:

<App>
  <JavaScript>

    var InterApp = require("FuseJS/InterApp");

    module.exports = {
      onGetPaymentURL: function (res) {

        if (JSON.parse(res.json).source != null) {

          if (JSON.parse(res.json).source.indexOf("mobilepaypos://") >= 0) {

            var uri = JSON.parse(res.json).source.between("href=\"", "\"").replace(/&amp;/g, '&');

            if (uri != "") {

              InterApp.launchUri(uri);

            }

          }

        }

      },
      onProgressChanged: function (res) {

    	getPaymentURL.value = true;

    	setTimeout(function () {

    		getPaymentURL.value = false;

    	}, 10);

    	}
    };

  </JavaScript>
  <WebView ProgressChanged="{onProgressChanged}">
    <WhileTrue Value="{getPaymentURL}">
      <EvaluateJS Handler="{onGetPaymentURL}">
        var result = {
          url : document.location.href,
          source : document.documentElement.innerHTML
        };
        return result;
      </EvaluateJS>
    </WhileTrue>
  </WebView>
</App>