I haven't heard any feedback on this, but I went ahead and opened a PR with an 
implementation of option #1 below:

https://github.com/apache/cordova-plugin-inappbrowser/pull/154

Note, if the current app is not one of the targets, then the current behavior 
stays the same. This only impacts Intents where the current app is one of the 
targets.

I'd certainly appreciate feedback on the implementation and a review of the PR!

Thanks,
Dan 

-----Original Message-----
From: Dan Polivy [mailto:d...@cellartracker.com] 
Sent: Monday, March 07, 2016 2:51 PM
To: 'dev@cordova.apache.org' <dev@cordova.apache.org>
Subject: [DISCUSS] Android InAppBrowser circular loop with deep links

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to