user836026 user836026 - 4 months ago 43
iOS Question

iOS custom URL schemes vs. Universal Links and Android counterpart

I'm looking for functionality where when a user receive a message, let's say through whatsapp app, containing a link starting with certain scheme (prefix) my app will be invoked when user tab on that link.

I understood this feature already available as "custom URL schemes" but I also notice now also Universal Links have similar thing, so is there any issue with "custom URL schemes" , because I don't want to use Universal Links because I don't want my app to be restricted to iOS 9.

Moreover, it looks Android also have this feature of customer URL, but again, on the latest Android version 6.0, it's mentioned here that they also have "App Links" feature which only work on Android 6.0, so again what is the difference between the two.

I don't want to restrict my app to work on only iOS9 or Android 9. So I guess the traditional "custom URL schemes" is more attractive for me for the time being.

Also, I want to make sure if "custom URL schemes" will work when user tab n a link on whatsapp app or it will only work if the link on the web browser or mail.

Answer

URLs with custom schemes don't get displayed as links in many Android applications (SMS, E-Mail, WhatsApp, Hangouts, you name it), which de facto make them unopenable by your application. iOS however does not allow for defining scheme + host + path like android does.

One possible (hacky) solution to this is browser sniffing (I know, evil, but so are non-standard extensions to well-defined behavior, especially if nothing was broken in the first place) at the resource you expose over a URL reachable over HTTP(s).

You could check if the request origins from the iOS-platform you offer native apps for; then you would have to make sure that the device has your application installed (this is getting uglier and uglier; see here for example) and then, only then redirect to yourapp://the-rest-of-your/uri, which causes a prompt shown to the user whether they want to open the address inside the application or not. (Tested on an iPhone 4 with iOS 8, Safari browser.)

Comments