@capawesome/capacitor-device-info 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CapawesomeCapacitorDeviceInfo.podspec +21 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +29 -0
  4. package/README.md +264 -0
  5. package/android/build.gradle +58 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/DeviceInfo.java +119 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/DeviceInfoPlugin.java +106 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/classes/results/GetIdResult.java +23 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/classes/results/GetInfoResult.java +98 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/classes/results/GetUptimeResult.java +22 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/interfaces/Callback.java +5 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/interfaces/NonEmptyResultCallback.java +7 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/deviceinfo/interfaces/Result.java +7 -0
  15. package/android/src/main/res/.gitkeep +0 -0
  16. package/dist/docs.json +413 -0
  17. package/dist/esm/definitions.d.ts +203 -0
  18. package/dist/esm/definitions.js +2 -0
  19. package/dist/esm/definitions.js.map +1 -0
  20. package/dist/esm/index.d.ts +4 -0
  21. package/dist/esm/index.js +7 -0
  22. package/dist/esm/index.js.map +1 -0
  23. package/dist/esm/web.d.ts +13 -0
  24. package/dist/esm/web.js +130 -0
  25. package/dist/esm/web.js.map +1 -0
  26. package/dist/plugin.cjs.js +144 -0
  27. package/dist/plugin.cjs.js.map +1 -0
  28. package/dist/plugin.js +147 -0
  29. package/dist/plugin.js.map +1 -0
  30. package/ios/Plugin/Classes/Results/GetIdResult.swift +16 -0
  31. package/ios/Plugin/Classes/Results/GetInfoResult.swift +66 -0
  32. package/ios/Plugin/Classes/Results/GetUptimeResult.swift +16 -0
  33. package/ios/Plugin/DeviceInfo.swift +89 -0
  34. package/ios/Plugin/DeviceInfoPlugin.swift +64 -0
  35. package/ios/Plugin/Info.plist +24 -0
  36. package/ios/Plugin/PrivacyInfo.xcprivacy +23 -0
  37. package/ios/Plugin/Protocols/Result.swift +5 -0
  38. package/package.json +91 -0
@@ -0,0 +1,98 @@
1
+ package io.capawesome.capacitorjs.plugins.deviceinfo.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSObject;
6
+ import io.capawesome.capacitorjs.plugins.deviceinfo.interfaces.Result;
7
+ import org.json.JSONObject;
8
+
9
+ public class GetInfoResult implements Result {
10
+
11
+ @Nullable
12
+ private final Integer androidSdkVersion;
13
+
14
+ @NonNull
15
+ private final String deviceType;
16
+
17
+ @Nullable
18
+ private final Integer iosVersion;
19
+
20
+ private final boolean isVirtual;
21
+
22
+ @NonNull
23
+ private final String manufacturer;
24
+
25
+ @NonNull
26
+ private final String model;
27
+
28
+ @Nullable
29
+ private final String name;
30
+
31
+ @NonNull
32
+ private final String operatingSystem;
33
+
34
+ @NonNull
35
+ private final String osVersion;
36
+
37
+ @NonNull
38
+ private final String platform;
39
+
40
+ @Nullable
41
+ private final Long totalMemory;
42
+
43
+ @Nullable
44
+ private final Long usedMemory;
45
+
46
+ @Nullable
47
+ private final String webViewVersion;
48
+
49
+ public GetInfoResult(
50
+ @Nullable Integer androidSdkVersion,
51
+ @NonNull String deviceType,
52
+ @Nullable Integer iosVersion,
53
+ boolean isVirtual,
54
+ @NonNull String manufacturer,
55
+ @NonNull String model,
56
+ @Nullable String name,
57
+ @NonNull String operatingSystem,
58
+ @NonNull String osVersion,
59
+ @NonNull String platform,
60
+ @Nullable Long totalMemory,
61
+ @Nullable Long usedMemory,
62
+ @Nullable String webViewVersion
63
+ ) {
64
+ this.androidSdkVersion = androidSdkVersion;
65
+ this.deviceType = deviceType;
66
+ this.iosVersion = iosVersion;
67
+ this.isVirtual = isVirtual;
68
+ this.manufacturer = manufacturer;
69
+ this.model = model;
70
+ this.name = name;
71
+ this.operatingSystem = operatingSystem;
72
+ this.osVersion = osVersion;
73
+ this.platform = platform;
74
+ this.totalMemory = totalMemory;
75
+ this.usedMemory = usedMemory;
76
+ this.webViewVersion = webViewVersion;
77
+ }
78
+
79
+ @Override
80
+ @NonNull
81
+ public JSObject toJSObject() {
82
+ JSObject result = new JSObject();
83
+ result.put("androidSdkVersion", androidSdkVersion == null ? JSONObject.NULL : androidSdkVersion);
84
+ result.put("deviceType", deviceType);
85
+ result.put("iosVersion", iosVersion == null ? JSONObject.NULL : iosVersion);
86
+ result.put("isVirtual", isVirtual);
87
+ result.put("manufacturer", manufacturer);
88
+ result.put("model", model);
89
+ result.put("name", name == null ? JSONObject.NULL : name);
90
+ result.put("operatingSystem", operatingSystem);
91
+ result.put("osVersion", osVersion);
92
+ result.put("platform", platform);
93
+ result.put("totalMemory", totalMemory == null ? JSONObject.NULL : totalMemory);
94
+ result.put("usedMemory", usedMemory == null ? JSONObject.NULL : usedMemory);
95
+ result.put("webViewVersion", webViewVersion == null ? JSONObject.NULL : webViewVersion);
96
+ return result;
97
+ }
98
+ }
@@ -0,0 +1,22 @@
1
+ package io.capawesome.capacitorjs.plugins.deviceinfo.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.deviceinfo.interfaces.Result;
6
+
7
+ public class GetUptimeResult implements Result {
8
+
9
+ private final long uptime;
10
+
11
+ public GetUptimeResult(long uptime) {
12
+ this.uptime = uptime;
13
+ }
14
+
15
+ @Override
16
+ @NonNull
17
+ public JSObject toJSObject() {
18
+ JSObject result = new JSObject();
19
+ result.put("uptime", uptime);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.deviceinfo.interfaces;
2
+
3
+ public interface Callback {
4
+ void error(Exception exception);
5
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.deviceinfo.interfaces;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public interface NonEmptyResultCallback<T extends Result> extends Callback {
6
+ void success(@NonNull T result);
7
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.deviceinfo.interfaces;
2
+
3
+ import com.getcapacitor.JSObject;
4
+
5
+ public interface Result {
6
+ JSObject toJSObject();
7
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,413 @@
1
+ {
2
+ "api": {
3
+ "name": "DeviceInfoPlugin",
4
+ "slug": "deviceinfoplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "getId",
10
+ "signature": "() => Promise<GetIdResult>",
11
+ "parameters": [],
12
+ "returns": "Promise<GetIdResult>",
13
+ "tags": [
14
+ {
15
+ "name": "since",
16
+ "text": "0.1.0"
17
+ }
18
+ ],
19
+ "docs": "Get a unique identifier for the device.\n\nOn **Android**, the identifier is the `ANDROID_ID` value, which is unique\nper app-signing key, user, and device. It is reset when the app is\nreinstalled after the signing key changes or the device is factory reset.\n\nOn **iOS**, the identifier is the `identifierForVendor` value, which is\nunique per vendor and device. It is reset when all apps from the vendor are\nuninstalled.\n\nOn **Web**, the identifier is a random UUID that is persisted in the\nbrowser's `localStorage`. It is reset when the browser storage is cleared.",
20
+ "complexTypes": [
21
+ "GetIdResult"
22
+ ],
23
+ "slug": "getid"
24
+ },
25
+ {
26
+ "name": "getInfo",
27
+ "signature": "() => Promise<GetInfoResult>",
28
+ "parameters": [],
29
+ "returns": "Promise<GetInfoResult>",
30
+ "tags": [
31
+ {
32
+ "name": "since",
33
+ "text": "0.1.0"
34
+ }
35
+ ],
36
+ "docs": "Get information about the device.",
37
+ "complexTypes": [
38
+ "GetInfoResult"
39
+ ],
40
+ "slug": "getinfo"
41
+ },
42
+ {
43
+ "name": "getUptime",
44
+ "signature": "() => Promise<GetUptimeResult>",
45
+ "parameters": [],
46
+ "returns": "Promise<GetUptimeResult>",
47
+ "tags": [
48
+ {
49
+ "name": "since",
50
+ "text": "0.1.0"
51
+ }
52
+ ],
53
+ "docs": "Get the time the device has been running since its last boot, in\nmilliseconds.\n\nOnly available on Android and iOS.",
54
+ "complexTypes": [
55
+ "GetUptimeResult"
56
+ ],
57
+ "slug": "getuptime"
58
+ }
59
+ ],
60
+ "properties": []
61
+ },
62
+ "interfaces": [
63
+ {
64
+ "name": "GetIdResult",
65
+ "slug": "getidresult",
66
+ "docs": "",
67
+ "tags": [
68
+ {
69
+ "text": "0.1.0",
70
+ "name": "since"
71
+ }
72
+ ],
73
+ "methods": [],
74
+ "properties": [
75
+ {
76
+ "name": "identifier",
77
+ "tags": [
78
+ {
79
+ "text": "'2f60cd8d-3b6a-4b3c-8f2e-1a2b3c4d5e6f'",
80
+ "name": "example"
81
+ },
82
+ {
83
+ "text": "0.1.0",
84
+ "name": "since"
85
+ }
86
+ ],
87
+ "docs": "The unique identifier of the device.",
88
+ "complexTypes": [],
89
+ "type": "string"
90
+ }
91
+ ]
92
+ },
93
+ {
94
+ "name": "GetInfoResult",
95
+ "slug": "getinforesult",
96
+ "docs": "",
97
+ "tags": [
98
+ {
99
+ "text": "0.1.0",
100
+ "name": "since"
101
+ }
102
+ ],
103
+ "methods": [],
104
+ "properties": [
105
+ {
106
+ "name": "androidSdkVersion",
107
+ "tags": [
108
+ {
109
+ "text": "34",
110
+ "name": "example"
111
+ },
112
+ {
113
+ "text": "0.1.0",
114
+ "name": "since"
115
+ }
116
+ ],
117
+ "docs": "The Android SDK version number (API level).\n\nReturns `null` on platforms other than Android.\n\nOnly available on Android.",
118
+ "complexTypes": [],
119
+ "type": "number | null"
120
+ },
121
+ {
122
+ "name": "deviceType",
123
+ "tags": [
124
+ {
125
+ "text": "0.1.0",
126
+ "name": "since"
127
+ }
128
+ ],
129
+ "docs": "The type of the device.",
130
+ "complexTypes": [
131
+ "DeviceType"
132
+ ],
133
+ "type": "DeviceType"
134
+ },
135
+ {
136
+ "name": "iosVersion",
137
+ "tags": [
138
+ {
139
+ "text": "17",
140
+ "name": "example"
141
+ },
142
+ {
143
+ "text": "0.1.0",
144
+ "name": "since"
145
+ }
146
+ ],
147
+ "docs": "The major version number of iOS.\n\nReturns `null` on platforms other than iOS.\n\nOnly available on iOS.",
148
+ "complexTypes": [],
149
+ "type": "number | null"
150
+ },
151
+ {
152
+ "name": "isVirtual",
153
+ "tags": [
154
+ {
155
+ "text": "0.1.0",
156
+ "name": "since"
157
+ }
158
+ ],
159
+ "docs": "Whether the app is running on a virtual device (simulator or emulator).",
160
+ "complexTypes": [],
161
+ "type": "boolean"
162
+ },
163
+ {
164
+ "name": "manufacturer",
165
+ "tags": [
166
+ {
167
+ "text": "'Apple'",
168
+ "name": "example"
169
+ },
170
+ {
171
+ "text": "0.1.0",
172
+ "name": "since"
173
+ }
174
+ ],
175
+ "docs": "The manufacturer of the device.",
176
+ "complexTypes": [],
177
+ "type": "string"
178
+ },
179
+ {
180
+ "name": "model",
181
+ "tags": [
182
+ {
183
+ "text": "'iPhone13,4'",
184
+ "name": "example"
185
+ },
186
+ {
187
+ "text": "0.1.0",
188
+ "name": "since"
189
+ }
190
+ ],
191
+ "docs": "The model identifier of the device.\n\nOn **iOS**, this is the internal model identifier (e.g. `iPhone13,4`), not\nthe marketing name.",
192
+ "complexTypes": [],
193
+ "type": "string"
194
+ },
195
+ {
196
+ "name": "name",
197
+ "tags": [
198
+ {
199
+ "text": "'iPhone'",
200
+ "name": "example"
201
+ },
202
+ {
203
+ "text": "0.1.0",
204
+ "name": "since"
205
+ }
206
+ ],
207
+ "docs": "The name of the device.\n\nOn **iOS 16 and newer**, a generic device name (e.g. `iPhone`) is returned\nunless the app has the required entitlement.\n\nReturns `null` if the name cannot be determined.",
208
+ "complexTypes": [],
209
+ "type": "string | null"
210
+ },
211
+ {
212
+ "name": "operatingSystem",
213
+ "tags": [
214
+ {
215
+ "text": "0.1.0",
216
+ "name": "since"
217
+ }
218
+ ],
219
+ "docs": "The operating system of the device.",
220
+ "complexTypes": [
221
+ "OperatingSystem"
222
+ ],
223
+ "type": "OperatingSystem"
224
+ },
225
+ {
226
+ "name": "osVersion",
227
+ "tags": [
228
+ {
229
+ "text": "'17.5'",
230
+ "name": "example"
231
+ },
232
+ {
233
+ "text": "0.1.0",
234
+ "name": "since"
235
+ }
236
+ ],
237
+ "docs": "The version of the operating system.",
238
+ "complexTypes": [],
239
+ "type": "string"
240
+ },
241
+ {
242
+ "name": "platform",
243
+ "tags": [
244
+ {
245
+ "text": "0.1.0",
246
+ "name": "since"
247
+ }
248
+ ],
249
+ "docs": "The platform the app is running on.",
250
+ "complexTypes": [
251
+ "Platform"
252
+ ],
253
+ "type": "Platform"
254
+ },
255
+ {
256
+ "name": "totalMemory",
257
+ "tags": [
258
+ {
259
+ "text": "4294967296",
260
+ "name": "example"
261
+ },
262
+ {
263
+ "text": "0.1.0",
264
+ "name": "since"
265
+ }
266
+ ],
267
+ "docs": "The total amount of memory of the device, in bytes.\n\nReturns `null` if the total memory cannot be determined.\n\nOnly available on Android and iOS.",
268
+ "complexTypes": [],
269
+ "type": "number | null"
270
+ },
271
+ {
272
+ "name": "usedMemory",
273
+ "tags": [
274
+ {
275
+ "text": "134217728",
276
+ "name": "example"
277
+ },
278
+ {
279
+ "text": "0.1.0",
280
+ "name": "since"
281
+ }
282
+ ],
283
+ "docs": "The amount of memory used by the app, in bytes.\n\nReturns `null` if the used memory cannot be determined.\n\nOnly available on Android and iOS.",
284
+ "complexTypes": [],
285
+ "type": "number | null"
286
+ },
287
+ {
288
+ "name": "webViewVersion",
289
+ "tags": [
290
+ {
291
+ "text": "'126.0.6478.40'",
292
+ "name": "example"
293
+ },
294
+ {
295
+ "text": "0.1.0",
296
+ "name": "since"
297
+ }
298
+ ],
299
+ "docs": "The version of the WebView that renders the app.\n\nOn **iOS**, the version of the operating system is returned, because the\nWebKit version is tied to it.\n\nReturns `null` if the WebView version cannot be determined.",
300
+ "complexTypes": [],
301
+ "type": "string | null"
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ "name": "GetUptimeResult",
307
+ "slug": "getuptimeresult",
308
+ "docs": "",
309
+ "tags": [
310
+ {
311
+ "text": "0.1.0",
312
+ "name": "since"
313
+ }
314
+ ],
315
+ "methods": [],
316
+ "properties": [
317
+ {
318
+ "name": "uptime",
319
+ "tags": [
320
+ {
321
+ "text": "123456789",
322
+ "name": "example"
323
+ },
324
+ {
325
+ "text": "0.1.0",
326
+ "name": "since"
327
+ }
328
+ ],
329
+ "docs": "The time the device has been running since its last boot, in milliseconds.",
330
+ "complexTypes": [],
331
+ "type": "number"
332
+ }
333
+ ]
334
+ }
335
+ ],
336
+ "enums": [],
337
+ "typeAliases": [
338
+ {
339
+ "name": "DeviceType",
340
+ "slug": "devicetype",
341
+ "docs": "The type of a device.\n\n- `phone`: A handheld phone-sized device.\n- `tablet`: A tablet-sized device.\n- `desktop`: A desktop or laptop computer.\n- `tv`: A television or set-top box.\n- `unknown`: The type could not be determined.",
342
+ "types": [
343
+ {
344
+ "text": "'phone'",
345
+ "complexTypes": []
346
+ },
347
+ {
348
+ "text": "'tablet'",
349
+ "complexTypes": []
350
+ },
351
+ {
352
+ "text": "'desktop'",
353
+ "complexTypes": []
354
+ },
355
+ {
356
+ "text": "'tv'",
357
+ "complexTypes": []
358
+ },
359
+ {
360
+ "text": "'unknown'",
361
+ "complexTypes": []
362
+ }
363
+ ]
364
+ },
365
+ {
366
+ "name": "OperatingSystem",
367
+ "slug": "operatingsystem",
368
+ "docs": "The operating system of a device.",
369
+ "types": [
370
+ {
371
+ "text": "'android'",
372
+ "complexTypes": []
373
+ },
374
+ {
375
+ "text": "'ios'",
376
+ "complexTypes": []
377
+ },
378
+ {
379
+ "text": "'windows'",
380
+ "complexTypes": []
381
+ },
382
+ {
383
+ "text": "'mac'",
384
+ "complexTypes": []
385
+ },
386
+ {
387
+ "text": "'unknown'",
388
+ "complexTypes": []
389
+ }
390
+ ]
391
+ },
392
+ {
393
+ "name": "Platform",
394
+ "slug": "platform",
395
+ "docs": "The platform an app is running on.",
396
+ "types": [
397
+ {
398
+ "text": "'android'",
399
+ "complexTypes": []
400
+ },
401
+ {
402
+ "text": "'ios'",
403
+ "complexTypes": []
404
+ },
405
+ {
406
+ "text": "'web'",
407
+ "complexTypes": []
408
+ }
409
+ ]
410
+ }
411
+ ],
412
+ "pluginConfigs": []
413
+ }