Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter mobile OS detection

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?

like image 952
Daniel Barde Avatar asked May 31 '13 14:05

Daniel Barde


2 Answers

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/

like image 151
Web Developer in Pune Avatar answered Sep 22 '22 16:09

Web Developer in Pune


Load lib.

$this->load->library('user_agent');

use this function to detect is mobile

$mobile=$this->agent->is_mobile();
if($mobile){
  //your code
}
like image 43
Kundan Picker Avatar answered Sep 24 '22 16:09

Kundan Picker