Reputation: 41
I want to redirect user to my Play Store application page, when they type some url in their mobile browser. I tried following code, but it redirect to play store website instead of Play Store app in android phone.
<script type="text/javascript">
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location = "http://play.google.com/store/apps/details?id=com.example";
}
</script>
After some searching on google I found that I have to use market url. Than I changed code as follow. But still no luck. This code is not redirecting anywhere.
<script type="text/javascript">
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location = "market://details?id=com.example";
}
</script>
Can anyone help me to identify what I missed in this?
Upvotes: 4
Views: 3713
Reputation: 81
Did you check the following url :
https://developer.android.com/distribute/tools/promote/linking.html#OpeningPublisher
For example if I try browsing the following url mentioned in above site
http://play.google.com/store/apps/details?id=com.google.android.apps.maps
it opens map app in playstore in my phone. The point is though the particular device should have playstore app installed.
Upvotes: 1