Redirect your users to your app in the appropriate app store.
This package is auto-updated.
Last update: 2021-02-23 21:38:15 UTC
Have an app that you need to direct your users to? Send them to the correct app store with this handy class. Requires PHP 7+.
composer require mattsparks/appstoreredirect
<?php require __DIR__ . '/vendor/autoload.php'; use AppStoreRedirect\AppStoreRedirect; $config = [ 'platforms' => [ 'iOS' => [ 'path' => 'https://itunes.apple.com/us/app/example-app-name/id1234567890', 'message' => 'Sending you to the Apple App Store', ], 'androidos' => [ 'path' => 'https://play.google.com/store/apps/details?id=com.example.app', 'message' => 'Sending you to the Google Play Store', ], ], 'delay' => 5, 'fallback' => [ 'path' => 'http://example.com', ], ]; $redirect = new AppStoreRedirect($config); $redirect->run();
|platform||iOS, androidos||The platform being targeted. A path is required, message is optional.|
|delay||0 - ?||Number of seconds to delay redirect. optional|
|fallback||path||A fallback path should a platform not be matched. optional|
Note: Other platforms are likely supported. Under the hood this uses Mobile Detect to determine the platform being used. I've only tested iOS and Android so far and can only vouch for those.
Contributions are very welcome!
- Follow the PSR-2 Standard
- Create a feature branch.
- Send a pull request.