cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Polivy <...@cellartracker.com>
Subject [DISCUSS] Android InAppBrowser circular loop with deep links
Date Mon, 07 Mar 2016 22:51:25 GMT
Hi folks,

I've been working on adding deep linking/Universal links to my app, and ran into an issue
with the InAppBrowser on Android that I'd appreciate some feedback on. For those not familiar,
deep linking allows the app to handle standard HTTP/HTTPS urls for a given website within
the app itself.

On Android, you can add an intent-filter to your manifest that says the app handles URLs for
www.example.com<http://www.example.com>. The problem is, if your app later wants to
direct the user to www.example.com<http://www.example.com> in the browser (using the
inappbrowser plugin with "_system" as the target), it's very hard to do so. Because the app
itself defines a handler for that URL, it is the default action that gets executed. And thus
you can end up with a circular loop where it tries to launch the app again (and in my case,
crashes - but that may be a separate issue).

I see a couple of ways of addressing this, and would appreciate feedback on what others think
is the best option (or other options I might have overlooked). I'm happy to submit a PR.


1)      When opening an external URL where the current app is one of the intents that can
handle it, instead of the default behavior we create a custom chooser that has all intent
targets EXCEPT the current app. The downside to this approach is that no "default" can be
set for future occurrences, so a chooser will always be shown. (Note, if the URL to be opened
does not have this app as an intent target, then the current behavior will apply.)

2)      I don't know if there's any reliable way to find the default browser on the device,
but if there is, we can explicitly set the component for the Intent so it opens in the browser.
As a fallback, we could use the Android System Browser, or Chrome, depending on OS version.
I'd prefer this if there was a good way to get the default browser, but so far I haven't found
one.

Here's the bug:
https://issues.apache.org/jira/browse/CB-10795

Thanks,
Dan


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message