-1

I will like a code i could embed on my site that can detect Android mobile device and prompt the user to download my Android app from Play Store.

Mavtrevor
  • 11
  • 3

3 Answers3

0

You can check this out https://github.com/serbanghita/Mobile-Detect

Use it to detect if your site is browsed from a mobile device, if yes then display a play store button that links your users to the play store.

TheBokiya
  • 600
  • 5
  • 19
0

You can use javascript to detect what type of device.

Detect Android phone via Javascript / jQuery

After you detect an android device, just redirect the user to the play store url of your app and the play store app will launch.

In wordpress specifically, you can add javascript to the page or to the entire site. http://codex.wordpress.org/Using_Javascript

So, you you would add something similar to the following.

<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
  // Do something!
  // Redirect to Android-site?
  window.location = 'http://google.com';
}
</script>

I would probably suggest starting with trying it on a single post, probably the home page.

Kalel Wade
  • 7,226
  • 2
  • 37
  • 54
  • How can i implement it on a Wordpress site? I Just want to notify the visitor that there is an Android app and suggest he downloads and install it. – Mavtrevor May 09 '14 at 04:56
0

It's too late but someone may get help. The most used Way for this purpose is to include a link to Play Store/App Store Application in Footer if user is visiting from a Mobile Device.

I Hope this Code works for you

// First Make two divs of Android App Link and iOS App Link with display none in Footer
// Then Call this function on Page Load

function showAppLink() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;

if (/android/i.test(userAgent)) {
    // Display Your Android App Link
    return;
}

// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
    // Display Your iOS App Link
    return;
}
}
Mohammad Mahroz
  • 412
  • 4
  • 13