Skip to content

Instantly share code, notes, and snippets.

@sunnyluthra
Created October 31, 2014 05:57
Show Gist options
  • Save sunnyluthra/c3b2aa68ab3540db1791 to your computer and use it in GitHub Desktop.
Save sunnyluthra/c3b2aa68ab3540db1791 to your computer and use it in GitHub Desktop.
Redirect to playstore or appstore
define("PLAYSTORE_LINK", "");
define("APPSTORE_LINK", "");
sny_os_redirect();
function sny_os_redirect() {
if(sny_if_android() && PLAYSTORE_LINK){
header("Location: " . PLAYSTORE_LINK);
}elseif(sny_if_ios() && APPSTORE_LINK){
header("Location: ".APPSTORE_LINK);
}
}
function sny_if_android() {
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
return stripos($ua, 'android');
}
function sny_if_ios() {
$iPod = stripos($_SERVER['HTTP_USER_AGENT'], "iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'], "iPad");
return $iPod || $iPhone || $iPad ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment