Jan 19th
2010

Porting Your CodeIgniter App to the iPhone

Recently, I had to add and iPhone interface for a web based app that we had built in CodeIgniter.  A quick look at the built in CodeIgniter User Agent Class shows a handy is_mobile() function.

Since we needed all the same data for both views, all we really needed to do was sniff for the user agent, and pass to an iPhone specific view if is_mobile() is true.


if ( $this->agent->is_mobile()) {
	$this->load->view('mobile/index', $data);
}
else {
        $this->load->view('includes/header');
	$this->load->view('schedule/schedule_view', $data);
	$this->load->view('includes/footer');
}

The mobile/index view was built entirely in jQTouch which is an absolute joy to work with.  Total of 3 hours from no iPhone interface to fully functional iPhone interface in CodeIgniter with the help of is_mobile() and jQTouch.  We are lucky to be working with such great open source projects.

Next Post → ← Previous Post