Skip to content Skip to sidebar Skip to footer

Branch.io: Javascript Detect Whether Mobile App Is Installed

I have a web page where I want a particular link on a page to open our native mobile app if the app is installed, and if not, do what it is currently doing (which submits a form).

Solution 1:

Alex from Branch.io here:

Unfortunately the has_app parameter is not especially reliable. It's good enough for switching a button between displaying an Open or an Install label, but ideally you don't want to use it for functional things. This is a limitation caused by iOS: Apple doesn't allow web pages to query for which apps are installed on a device (for obvious privacy reasons), so Branch has to rely on cookie matching. This means if we can't match the cookie, or haven't seen the user recently, or the user clears their device cache, or the user has uninstalled the app since the last time Branch saw them, the value of has_app will be incorrect.

HOWEVER, even though Apple doesn't allow web pages to query access this data, iOS itself can still act on it. Universal Links do exactly this — when the user opens a Universal Link (which includes Branch links, assuming you got all the configuration done), the app will open if it is installed. If it is not installed, the user will be sent to the URL of the link. You just need to put a Branch link behind that button.

Note however that this doesn't work for form submission buttons, so you would need to come up with some UX workaround for this. Or you might be able to find a way to submit the form after a delay if the app doesn't open, by using a Javascript timer.

Post a Comment for "Branch.io: Javascript Detect Whether Mobile App Is Installed"