I've been able to detect what mobile device a user is using with CodeIgniter, but I haven't been able to detect what operating system the current mobile device is running.
Let's say someone is using a Samsung mobile device that runs on Android, and another is using a normal Java mobile operating system that's still Samsung. How can I check to see the which operating system each user is on?
Download library from http://mobiledetect.net Put Mobile_Detect.php in to 'libraries'
inside main controller
public function index() {
$this -> load -> library('Mobile_Detect');
$detect = new Mobile_Detect();
if ($detect->isMobile() || $detect->isTablet() || $detect->isAndroidOS()) {
header("Location: ".$this->config->item('base_url')."/mobile"); exit;
}
}
Find documentation on https://dwij.net/mobile-os-detection-in-php-codeigniter/
Load lib.
$this->load->library('user_agent');
use this function to detect is mobile
$mobile=$this->agent->is_mobile();
if($mobile){
//your code
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With