Detecting the device

Different devices offer different capabilities and hence for an application developer, it becomes important to identify the exact device, so that it can respond to the events in the most appropriate way. This recipe describes how we can detect the device on which the application is being run.

How to do it...

Carry out the following steps:

  1. Create and open a new file ch01_02.js in the ch01 folder and paste the following code into it:
    Ext.setup({
      onReady: function() {
        if (Ext.is.Android)
          Ext.Msg.alert("INFO", "Welcome Android user!");
          
        if (Ext.is.Blackberry)
          Ext.Msg.alert("INFO", "Welcome Blackberry user!");
          
        if (Ext.is.iPad)
          Ext.Msg.alert("INFO", "Welcome iPad user!");
      }
    });
  2. Remove the following line from index.html:
    <script type="text/javascript" ...

Get Sencha Touch Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.