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?