0
# Device & System Information
1
2
Core device information and system capabilities for identifying device characteristics, application details, and platform-specific features.
3
4
## Capabilities
5
6
### Device Information
7
8
Access to core device properties and characteristics available immediately after device ready.
9
10
```typescript { .api }
11
/**
12
* Device class providing static properties for device information
13
* All properties are available immediately after device ready event
14
*/
15
class Device {
16
/** Version of Cordova running on the device */
17
static cordova: string;
18
/** Name of device's model or product */
19
static model: string;
20
/** Operating system name (iOS, Android, etc.) */
21
static platform: string;
22
/** Device's Universally Unique Identifier */
23
static uuid: string;
24
/** Operating system version */
25
static version: string;
26
/** Device's manufacturer */
27
static manufacturer: string;
28
/** Whether the device is running on a simulator */
29
static isVirtual: boolean;
30
/** Device hardware serial number (Android only) */
31
static serial: string;
32
}
33
```
34
35
**Usage Examples:**
36
37
```typescript
38
import { Device } from 'ionic-native';
39
40
// Access device information
41
console.log('Device model: ' + Device.model);
42
console.log('Platform: ' + Device.platform);
43
console.log('UUID: ' + Device.uuid);
44
console.log('Version: ' + Device.version);
45
console.log('Cordova version: ' + Device.cordova);
46
47
// Check if running on simulator
48
if (Device.isVirtual) {
49
console.log('Running on simulator/emulator');
50
}
51
52
// Platform-specific logic
53
if (Device.platform === 'iOS') {
54
// iOS-specific code
55
} else if (Device.platform === 'Android') {
56
// Android-specific code
57
}
58
```
59
60
### Application Version Information
61
62
Retrieve application version details and metadata from the app bundle.
63
64
```typescript { .api }
65
/**
66
* AppVersion class for retrieving application version information
67
* All methods return promises with version-related data
68
*/
69
class AppVersion {
70
/**
71
* Get the name of the app from app bundle
72
* @returns Promise resolving to app name string
73
*/
74
static getAppName(): Promise<string>;
75
76
/**
77
* Get the package name/bundle identifier
78
* @returns Promise resolving to package name (e.g., com.example.app)
79
*/
80
static getPackageName(): Promise<string>;
81
82
/**
83
* Get the version code (build number)
84
* @returns Promise resolving to version code as string or number
85
*/
86
static getVersionCode(): Promise<string | number>;
87
88
/**
89
* Get the version number (display version)
90
* @returns Promise resolving to version number string (e.g., "1.2.3")
91
*/
92
static getVersionNumber(): Promise<string>;
93
}
94
```
95
96
**Usage Examples:**
97
98
```typescript
99
import { AppVersion } from 'ionic-native';
100
101
// Get app information
102
AppVersion.getAppName().then((name) => {
103
console.log('App name: ' + name);
104
});
105
106
AppVersion.getPackageName().then((packageName) => {
107
console.log('Package: ' + packageName);
108
});
109
110
AppVersion.getVersionNumber().then((version) => {
111
console.log('Version: ' + version);
112
});
113
114
AppVersion.getVersionCode().then((build) => {
115
console.log('Build: ' + build);
116
});
117
118
// Get all version info
119
async function getVersionInfo() {
120
try {
121
const name = await AppVersion.getAppName();
122
const packageName = await AppVersion.getPackageName();
123
const version = await AppVersion.getVersionNumber();
124
const build = await AppVersion.getVersionCode();
125
126
return {
127
name,
128
packageName,
129
version,
130
build
131
};
132
} catch (error) {
133
console.error('Error getting version info:', error);
134
}
135
}
136
```
137
138
### Debug Detection
139
140
Determine if the application is running in debug mode for development vs production logic.
141
142
```typescript { .api }
143
/**
144
* IsDebug class for detecting debug/development mode
145
*/
146
class IsDebug {
147
/**
148
* Check if the app is running in debug mode
149
* @returns Promise resolving to boolean indicating debug status
150
*/
151
static getIsDebug(): Promise<boolean>;
152
}
153
```
154
155
**Usage Examples:**
156
157
```typescript
158
import { IsDebug } from 'ionic-native';
159
160
// Check debug status
161
IsDebug.getIsDebug().then((isDebug) => {
162
if (isDebug) {
163
console.log('Running in debug mode');
164
// Enable debug features
165
} else {
166
console.log('Running in production mode');
167
// Disable debug features
168
}
169
});
170
171
// Conditional feature enabling
172
async function initializeApp() {
173
const isDebug = await IsDebug.getIsDebug();
174
175
if (isDebug) {
176
// Enable debugging tools
177
enableDebugger();
178
showDebugMenu();
179
}
180
181
// Continue normal app initialization
182
}
183
```
184
185
### Unique Device Identification
186
187
Get a unique identifier for the device for analytics, licensing, or security purposes.
188
189
```typescript { .api }
190
/**
191
* UniqueDeviceID class for getting device-specific unique identifier
192
*/
193
class UniqueDeviceID {
194
/**
195
* Get unique device identifier
196
* @returns Promise resolving to unique device ID string
197
*/
198
static get(): Promise<string>;
199
}
200
```
201
202
**Usage Examples:**
203
204
```typescript
205
import { UniqueDeviceID } from 'ionic-native';
206
207
// Get unique device ID
208
UniqueDeviceID.get().then((uuid) => {
209
console.log('Device ID: ' + uuid);
210
211
// Use for analytics tracking
212
analytics.setUserId(uuid);
213
214
// Use for device-specific settings
215
loadDeviceSettings(uuid);
216
});
217
218
// Error handling
219
UniqueDeviceID.get().then((uuid) => {
220
// Successfully got unique ID
221
return uuid;
222
}).catch((error) => {
223
console.error('Failed to get device ID:', error);
224
// Fallback to generated ID
225
return generateFallbackId();
226
});
227
```
228
229
### System Diagnostics
230
231
Check device capabilities and system status for troubleshooting and feature detection.
232
233
```typescript { .api }
234
/**
235
* Diagnostic class for system capability checking
236
*/
237
class Diagnostic {
238
/** Check if location services are enabled */
239
static isLocationEnabled(): Promise<boolean>;
240
241
/** Check if GPS location is available */
242
static isGpsLocationEnabled(): Promise<boolean>;
243
244
/** Check if network location is available */
245
static isNetworkLocationEnabled(): Promise<boolean>;
246
247
/** Check if camera is available */
248
static isCameraAvailable(): Promise<boolean>;
249
250
/** Check if Bluetooth is available */
251
static isBluetoothAvailable(): Promise<boolean>;
252
253
/** Check if Wi-Fi is available */
254
static isWifiAvailable(): Promise<boolean>;
255
256
/** Get location authorization status */
257
static getLocationAuthorizationStatus(): Promise<string>;
258
259
/** Request location authorization */
260
static requestLocationAuthorization(): Promise<string>;
261
262
/** Switch to device settings */
263
static switchToSettings(): Promise<any>;
264
}
265
```
266
267
**Usage Examples:**
268
269
```typescript
270
import { Diagnostic } from 'ionic-native';
271
272
// Check system capabilities
273
async function checkSystemCapabilities() {
274
try {
275
const locationEnabled = await Diagnostic.isLocationEnabled();
276
const cameraAvailable = await Diagnostic.isCameraAvailable();
277
const wifiAvailable = await Diagnostic.isWifiAvailable();
278
279
console.log('Location enabled:', locationEnabled);
280
console.log('Camera available:', cameraAvailable);
281
console.log('WiFi available:', wifiAvailable);
282
283
if (!locationEnabled) {
284
// Prompt user to enable location
285
const authStatus = await Diagnostic.requestLocationAuthorization();
286
if (authStatus !== 'GRANTED') {
287
// Direct user to settings
288
await Diagnostic.switchToSettings();
289
}
290
}
291
} catch (error) {
292
console.error('Error checking capabilities:', error);
293
}
294
}
295
```