We have an android app that is launched when the user is redirected to a custom protocol. We want to have the user redirect to the google/play store for the app if it isn't installed on their device.
For iOS we use something like this: Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps? ... however this doesn't work on android.
This is the basic workflow:
customProtocol://site.com?some=params
Any thoughts on how we can achieve this on android? Is it just not possible on android?
The Android app not installed error can be combated after resetting app permissions. Go to Settings > Apps > Reset App Preferences/Reset Application Permissions. After this, third-party software can be installed on your device.
Case 1 is easy you can use the following code: window. location = "mycoolapp://"; This will work if the app is installed on the device.
Open Chrome on your Android device. To the right of the address bar, tap More, then tap Settings. Tap Site settings, then select Pop-ups and redirects. Switch Pop-ups and redirects to Block (You should then see “Block sites from showing pop-ups and redirects (recommended)” under Pop-ups and redirects)
Any thoughts on how we can achieve this on android?
Not with a "custom protocol" (or, more correctly, a "custom scheme"). The pattern on Android is for you to use a URL that you control.
For example, the Barcode Scanner app has the following defined for its main scanning activity:
<!-- Allow web apps to launch Barcode Scanner by linking to http://zxing.appspot.com/scan. --> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="http" android:host="zxing.appspot.com" android:path="/scan"/> </intent-filter>
Then, any links to http://zxing.appspot.com/scan will do one of two things:
If the link is clicked from a browser on an Android device, and Barcode Scanner is installed, the user can choose between displaying the app or displaying the Web page associated with the link
If the link is clicked anywhere else (Android device without the app, other mobile device, desktop, notebook, etc.), the browser brings up the Web page for that URL, in which you can do whatever you want, including optionally redirecting to the Play Store
You could define a server-side URL that simply redirects to the application page in Google Play, and use that URL in an intent filter to be captured by your application:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With