]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * Provides a cross device way to get information about the device your application is running on. There are 3 different implementations:\r | |
3 | *\r | |
4 | * - Sencha Packager\r | |
5 | * - [Cordova](http://cordova.apache.org/docs/en/2.5.0/cordova_device_device.md.html#Device)\r | |
6 | * - Simulator\r | |
7 | *\r | |
8 | * ## Examples\r | |
9 | *\r | |
10 | * #### Device Information\r | |
11 | *\r | |
12 | * Getting the device information:\r | |
13 | *\r | |
14 | * Ext.application({\r | |
15 | * name: 'Sencha',\r | |
16 | *\r | |
17 | * // Remember that the Ext.device.Device class *must* be required\r | |
18 | * requires: ['Ext.device.Device'],\r | |
19 | *\r | |
20 | * launch: function() {\r | |
21 | * alert([\r | |
22 | * 'Device name: ' + Ext.device.Device.name,\r | |
23 | * 'Device platform: ' + Ext.device.Device.platform,\r | |
24 | * 'Device UUID: ' + Ext.device.Device.uuid\r | |
25 | * ].join('\n'));\r | |
26 | * }\r | |
27 | * });\r | |
28 | *\r | |
29 | * ### Custom Scheme URL\r | |
30 | *\r | |
31 | * Using custom scheme URL to application your application from other applications:\r | |
32 | *\r | |
33 | * Ext.application({\r | |
34 | * name: 'Sencha',\r | |
35 | * requires: ['Ext.device.Device'],\r | |
36 | * launch: function() {\r | |
37 | * if (Ext.device.Device.scheme) {\r | |
38 | * // the application was opened via another application. Do something:\r | |
39 | * alert('Applicaton pened via another application: ' + Ext.device.Device.scheme.url);\r | |
40 | * }\r | |
41 | *\r | |
42 | * // Listen for future changes\r | |
43 | * Ext.device.Device.on('schemeupdate', function(device, scheme) {\r | |
44 | * // the application was launched, closed, and then launched another from another application\r | |
45 | * // this means onReady wont be called again ('cause the application is already running in the \r | |
46 | * // background) - but this event will be fired\r | |
47 | * alert('Applicated reopened via another application: ' + scheme.url);\r | |
48 | * }, this);\r | |
49 | * }\r | |
50 | * });\r | |
51 | *\r | |
52 | * Of course, you must add the custom scheme URL you would like to use when packaging your application.\r | |
53 | * You can do this by setting the `URLScheme` property inside your `package.json` file (Sencha Native Packager configuration file):\r | |
54 | *\r | |
55 | * {\r | |
56 | * ...\r | |
57 | * "URLScheme": "sencha",\r | |
58 | * ...\r | |
59 | * }\r | |
60 | *\r | |
61 | * You can change the available URL scheme.\r | |
62 | *\r | |
63 | * You can then test it by packaging and installing the application onto a device/iOS Simulator, opening Safari and typing: `sencha:testing`.\r | |
64 | * The application will launch and it will `alert` the URL you specified.\r | |
65 | *\r | |
66 | * **PLEASE NOTE: This currently only works with the Sencha Native Packager. If you attempt to listen to this event when packaged with\r | |
67 | * PhoneGap or simply in the browser, it will not function.**\r | |
68 | *\r | |
69 | * @mixins Ext.device.device.Abstract\r | |
70 | */\r | |
71 | Ext.define('Ext.device.Device', {\r | |
72 | singleton: true,\r | |
73 | \r | |
74 | requires: [\r | |
75 | 'Ext.device.Communicator',\r | |
76 | 'Ext.device.device.Cordova',\r | |
77 | 'Ext.device.device.Simulator'\r | |
78 | ],\r | |
79 | \r | |
80 | constructor: function() {\r | |
81 | var browserEnv = Ext.browser.is;\r | |
82 | if (browserEnv.WebView) {\r | |
83 | if (browserEnv.Cordova) {\r | |
84 | return Ext.create('Ext.device.device.Cordova');\r | |
85 | }\r | |
86 | }\r | |
87 | \r | |
88 | return Ext.create('Ext.device.device.Simulator');\r | |
89 | }\r | |
90 | });\r |