29

Firefox does not fire intents for clicked links the way it should. Therefore one cannot launch their app by clicking a link in Firefox (which is possible in Chrome and other browsers).

Edit: Please keep in mind that this is a post from 2013.

The desired behavior is the following: On my website I have a link, that when clicked should launch my Android app. If the app is not installed, preferably its page in Google Play should be opened to download it.

Method

The way I implement it is with an "intent URI" of the form: intent://myhost.com/#Intent;scheme=myscheme;package=com.myapp;end

In the app I register an intent filter in my manifest and listen for an intent that matches. However, it is up to the browser to fire such an intent when the link is clicked, so that my app can start.

I have tested this method with various browsers, and it works on most of them. With the notable exception of Firefox. With other browsers either my app launches, or its page in Google Play loads (in case it's not installed on the device).

The method with the "intent URI" is the recommended one by Google. It works perfectly on Chrome and on some other browsers. There are also other methods. I have read many threads and articles about the possibilities. The main alternatives are:

Alternative methods

  1. using a custom scheme, like myscheme://mywebsite.com
  2. using a regular http link, like http://mywebsite.com

Alternative 1 is not recommended for two reasons: - I do not own such a scheme, it does not exist globally, it's wrong. Google was also using market://... to start the Google Play app, but they have admitted that this is wrong and should change. - If my app is not currently installed, it will not be started and most browsers display an error page, which is obviously undesirable.

Alternative 2 does not work on most browsers and seems to be deprecated in favor of the "intent URI" method.

Firefox in particular

only works with the custom scheme (alternative 1). In the case of a regular http link (alternative 2) it just loads the link and shows the website. In the case of the recommended "intent URI" method, it does nothing. Actually, it shows a dialog asking whether you want to launch the app, but when you click Yes, nothing happens. So it seems Firefox recognizes links like "intent://..." but doesn't handle them properly.

Q: What is the recommended method for launching an app from a link in Firefox? Why isn't the "intent URI" method supported by Firefox?

Related links: https://developers.google.com/chrome/mobile/docs/intents https://stackoverflow.com/a/3472228/1045941 (keep in mind that the thread is quite old)

Stan
  • 2,151
  • 1
  • 25
  • 33
  • Could this be helpful? https://support.mozilla.org/en-US/questions/977330 It seems that Forefox is bypassing the default Android Way of Handling intents – Display name Jan 14 '14 at 14:34
  • I haven't investigated this in a while, but did a quick test and it seems that it's still not working. In the link @Seppl posted they promise that it should be fixed in recent versions though. Does anyone have any new finding? – Stan Mar 21 '14 at 15:31
  • 1
    As far is I can see in my own installation of Firefox on Android there now is an android robot button in the top bar that starts an intent with page that is currently open – Display name Mar 24 '14 at 08:30
  • which version of Android you're using? – Onur A. Sep 04 '14 at 20:02
  • At that time I tested on 4.1.2, 2.3.6 and 2.3.3. On all of them the results were the same for Firefox. I haven't tested with the newest Android versions at the moment, nor with updated versions of Firefox since 2013. – Stan Sep 15 '14 at 20:50
  • If it's a bug from firefox you can't do much. If you have access to the webpage that is displayed, you could check which version of browser (mobile / firefox) and display the "intent" link for your targeted browser. – Vincent D. Nov 11 '14 at 23:44
  • The alternative 1 doesn't work for me - just white screen. I have a registered custom scheme (i.g. myscheme), when I click link (Magic) only I get is white screen (Chrome and default browser work). At the same time link MarketAppURL works in Firefox. What am I doing wrong? Firefox version: Mozilla/5.0 (Android; Mobile; rv:33.0) Gecko/33.0 Firefox/33.0 – MingalevME Nov 12 '14 at 14:56
  • I have the same problem, nothing works on Firefox 33.1 Android. The only thing to to is to redirect the user to the Play Store so they can open the app from there – Paranoid Android Nov 12 '14 at 15:46
  • I didn't know Web Intents, really interesting thema. I have read and seems only Chrome is the precursor and supports it right now, the other browsers will implement slowly. So i recommend you, use the 1 Alternate way right now-which i have used many times and works fine-, until all major browsers have full implemented it... – Sulfkain Nov 13 '14 at 16:19
  • 2
    Firefox supports the `intent:` scheme now: https://bugzilla.mozilla.org/show_bug.cgi?id=851693 – Jarett Millard Nov 03 '16 at 20:21

1 Answers1

1

One option would be to add a hidden iframe, something like:

<iframe src="myscheme://..." style="visibility: hidden"></iframe>

It is tested to work on firefox, but it won't work on chrome. You probably want to use some user agent detection, here's an example: http://www.mazdigital.com/blog/post/2014/deep-links-on-mobile-browsers-demystified/

Cash Lo
  • 1,052
  • 1
  • 8
  • 20