android - detect what is the phone via the browser -
i sending sms clients download app. in sms want place link, when opened on device, checks whether device has ios , automatically takes app store, if running android, takes google play.
how achieve approach ?
get user agent string , check of 'apple' or 'android'. android has following pattern:
phone pattern: 'android' + 'chrome/[.0-9]* mobile' tablet pattern: 'android' + 'chrome/[.0-9]* (?!mobile)'
apple appears have works 'apple' , 'iphone' in user agent strings.
edit
assuming want in javascript, have the link navigate html page. in head add this:
<script type="text/javascript"> $(document).ready(function () { if(navigator.useragent.indexof('android') != -1){ window.location.href = 'linktoplaystore'; }else if(navigator.useragent.indexof('iphone') != -1){ window.location.href = 'linktoapstore'; } } </javascript>
Comments
Post a Comment