I am trying to create a link that can be sent via email which when opened on an android device with my app installed will automatically open the correct page in my app.
I have gotten this partially working in a few different ways but have found a few problems that I was wondering if anyone has solutions to.
Attempt 1: Using a custom scheme: myapp://someItem. This works but some email applications do not treat this as a link as it is not http. Is there a way to force applications to treat it as a valid link? gmail for example.
Attempt 2: Using a http link with a host: http://com.myapp/someItem. This works as well but my app ends up registered to handle all http links which is not ideal.
Attempt 3: Using a http link with host and port: http://com.myapp:2345/someItem. This is my current solution with the only drawback being that when the link is opened it still gives the option of opening the link in a browser. Is there a way to stop the browser attempting to open my links?
Does anyone have a way to make links that will be treated as links by all applications and also be ignored by the browser when opening them?
This technique actually seems to be working on Android from what I can tell:
http://mobile.dzone.com/news/custom-url-schemes-phonegap
I haven’t tried it in a real production app yet, so your mileage may vary. What I’ve done is use that technique of creating a hidden iframe and attempting to set the location to the custom url scheme, and call the function from onload for the document. What I’ve seen so far (I’ve only tested it out on 2.2 and 2.3 devices) is that if I have an app installed that handles the custom scheme the app will launch, and if not the page will render.
Relatively clean single URL to cover both cases, and doesn’t ruin things like Twitter shares of the URL. A real production version might only do the hidden iframe probe if the request is coming from something that looks like a platform that might support the application to reduce the risk of incompatible desktop behavior.