Created
June 24, 2014 17:41
-
-
Save niraj-shah/afa15f8bf2698fc40a46 to your computer and use it in GitHub Desktop.
PHP file to redirect visitors to iOS or Android app files
This file contains 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
<?php | |
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { | |
$iPod = stripos( $_SERVER['HTTP_USER_AGENT'], "iPod" ); | |
$iPhone = stripos( $_SERVER['HTTP_USER_AGENT'], "iPhone" ); | |
$iPad = stripos( $_SERVER['HTTP_USER_AGENT'], "iPad" ); | |
$Android = stripos( $_SERVER['HTTP_USER_AGENT'], "Android" ); | |
$webOS = stripos( $_SERVER['HTTP_USER_AGENT'], "webOS" ); | |
// detect os version | |
if ( $iPod || $iPhone || $iPad ) { | |
// redirect to ipa file download | |
header( 'Location: itms-services://?action=download-manifest&url=https://apps.webniraj.com/my-app/my-app.plist' ); | |
die(); | |
} else if ( $Android ) { | |
// redirect to apk file download | |
header( 'Location: my-app.apk' ); | |
die(); | |
} | |
} else { | |
// add links to each version here for generic Browser support | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>items</key> | |
<array> | |
<dict> | |
<key>assets</key> | |
<array> | |
<dict> | |
<key>kind</key> | |
<string>software-package</string> | |
<key>url</key> | |
<string>http://apps.webniraj.com/my-app/my-app.ipa</string> | |
</dict> | |
<dict> | |
<key>kind</key> | |
<string>display-image</string> | |
<key>needs-shine</key> | |
<true/> | |
<key>url</key> | |
<string>http://apps.webniraj.com/my-app/iOS-57.png</string> | |
</dict> | |
<dict> | |
<key>kind</key> | |
<string>full-size-image</string> | |
<key>needs-shine</key> | |
<true/> | |
<key>url</key> | |
<string>http://apps.webniraj.com/my-app/iOS-512.png</string> | |
</dict> | |
</array> | |
<key>metadata</key> | |
<dict> | |
<key>bundle-identifier</key> | |
<string>com.webniraj.my-app</string> | |
<key>bundle-version</key> | |
<string>1.0</string> | |
<key>kind</key> | |
<string>software</string> | |
<key>subtitle</key> | |
<string>WebNiraj</string> | |
<key>title</key> | |
<string>My App</string> | |
</dict> | |
</dict> | |
</array> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment