Skip to content

Instantly share code, notes, and snippets.

@ethaizone
Last active May 24, 2022 17:56
Show Gist options
  • Save ethaizone/a8c8e20c680d510d758d6d2b3980f230 to your computer and use it in GitHub Desktop.
Save ethaizone/a8c8e20c680d510d758d6d2b3980f230 to your computer and use it in GitHub Desktop.
[PHP] Auto redirect to app store. (Android/IOS)
<?php
// android store
if (preg_match('#android#i', $_SERVER ['HTTP_USER_AGENT'])) {
header('Location: market://details?id=com.google.android.apps.maps');
exit;
}
// ios
if (preg_match('#(iPad|iPhone|iPod)#i', $_SERVER ['HTTP_USER_AGENT'])) {
header('Location: itms://itunes.apple.com/us/app/google-maps-real-time-navigation/id585027354?mt=8');
exit;
}
// for another os
echo $_SERVER ['HTTP_USER_AGENT'];
@shalomanov
Copy link

Seems good but it does not work on some devices. Safari on some iOS devices cant understand itms type. So it is necessary to paste good old Location: https://itunes.apple.com...
Probably some android does the same (i have not seen that yet) but I used the same way for android Location: https://play.google.com/store/apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment