Last active
August 12, 2019 19:01
-
-
Save brianwebb01/0c095c706d1e5bd6e4dacf24d87f9319 to your computer and use it in GitHub Desktop.
How to make a link click open a native SMS message on android or ios
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
<?php | |
//uses https://packagist.org/packages/mobiledetect/mobiledetectlib | |
$body = "Hey this is a new sms message"; | |
$url = "http://example.com/path/to/fallback/url"; | |
$detect = new MobileDetect(); | |
if ($detect->isMobile()) { | |
if ($detect->isIphone()) { | |
$url = "sms:" . $phone . "&body=" . rawurlencode($body); | |
} | |
if ($detect->isAndroidOS()) { | |
$url = "sms://" . $phone . "?body=" . rawurlencode($body); | |
} | |
}//end if | |
header("Location: {$url}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment