Created
October 31, 2014 05:57
-
-
Save sunnyluthra/c3b2aa68ab3540db1791 to your computer and use it in GitHub Desktop.
Redirect to playstore or appstore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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