@capgo/capacitor-permissions 0.0.0-stage → 8.2.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.
- package/CapgoCapacitorPermissions.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +40 -0
- package/README.md +433 -2
- package/android/build.gradle +68 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/kotlin/app/capgo/permissions/Permissions.kt +263 -0
- package/android/src/main/kotlin/app/capgo/permissions/PermissionsPlugin.kt +273 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +490 -0
- package/dist/esm/definitions.d.ts +159 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +27 -0
- package/dist/esm/web.js +113 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +127 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +130 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/PermissionsPlugin/PermissionStatusMapper.swift +139 -0
- package/ios/Sources/PermissionsPlugin/Permissions.swift +222 -0
- package/ios/Sources/PermissionsPlugin/PermissionsPlugin.swift +123 -0
- package/ios/Tests/PermissionsPluginTests/PermissionsTests.swift +73 -0
- package/package.json +93 -4
package/dist/docs.json
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "PermissionsPlugin",
|
|
4
|
+
"slug": "permissionsplugin",
|
|
5
|
+
"docs": "Cross-platform permissions API for Capacitor apps.",
|
|
6
|
+
"tags": [
|
|
7
|
+
{
|
|
8
|
+
"text": "8.0.0",
|
|
9
|
+
"name": "since"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"methods": [
|
|
13
|
+
{
|
|
14
|
+
"name": "check",
|
|
15
|
+
"signature": "(options: PermissionOptions) => Promise<PermissionStatusResult>",
|
|
16
|
+
"parameters": [
|
|
17
|
+
{
|
|
18
|
+
"name": "options",
|
|
19
|
+
"docs": "",
|
|
20
|
+
"type": "PermissionOptions"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"returns": "Promise<PermissionStatusResult>",
|
|
24
|
+
"tags": [
|
|
25
|
+
{
|
|
26
|
+
"name": "param",
|
|
27
|
+
"text": "options.permission Logical permission to inspect."
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"docs": "Check the current status of one permission without prompting the user.",
|
|
31
|
+
"complexTypes": [
|
|
32
|
+
"PermissionStatusResult",
|
|
33
|
+
"PermissionOptions"
|
|
34
|
+
],
|
|
35
|
+
"slug": "check"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "request",
|
|
39
|
+
"signature": "(options: PermissionOptions) => Promise<PermissionStatusResult>",
|
|
40
|
+
"parameters": [
|
|
41
|
+
{
|
|
42
|
+
"name": "options",
|
|
43
|
+
"docs": "",
|
|
44
|
+
"type": "PermissionOptions"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"returns": "Promise<PermissionStatusResult>",
|
|
48
|
+
"tags": [
|
|
49
|
+
{
|
|
50
|
+
"name": "param",
|
|
51
|
+
"text": "options.permission Logical permission to request."
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"docs": "Request one permission from the user. On Android, shows the system dialog when needed.",
|
|
55
|
+
"complexTypes": [
|
|
56
|
+
"PermissionStatusResult",
|
|
57
|
+
"PermissionOptions"
|
|
58
|
+
],
|
|
59
|
+
"slug": "request"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "checkMultiple",
|
|
63
|
+
"signature": "(options: MultiplePermissionOptions) => Promise<MultiplePermissionStatusResult>",
|
|
64
|
+
"parameters": [
|
|
65
|
+
{
|
|
66
|
+
"name": "options",
|
|
67
|
+
"docs": "",
|
|
68
|
+
"type": "MultiplePermissionOptions"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"returns": "Promise<MultiplePermissionStatusResult>",
|
|
72
|
+
"tags": [
|
|
73
|
+
{
|
|
74
|
+
"name": "param",
|
|
75
|
+
"text": "options.permissions List of permissions to inspect."
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"docs": "Check several permissions without prompting.",
|
|
79
|
+
"complexTypes": [
|
|
80
|
+
"MultiplePermissionStatusResult",
|
|
81
|
+
"MultiplePermissionOptions"
|
|
82
|
+
],
|
|
83
|
+
"slug": "checkmultiple"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "requestMultiple",
|
|
87
|
+
"signature": "(options: MultiplePermissionOptions) => Promise<MultiplePermissionStatusResult>",
|
|
88
|
+
"parameters": [
|
|
89
|
+
{
|
|
90
|
+
"name": "options",
|
|
91
|
+
"docs": "",
|
|
92
|
+
"type": "MultiplePermissionOptions"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"returns": "Promise<MultiplePermissionStatusResult>",
|
|
96
|
+
"tags": [
|
|
97
|
+
{
|
|
98
|
+
"name": "param",
|
|
99
|
+
"text": "options.permissions List of permissions to request."
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"docs": "Request several permissions sequentially so dialogs are not shown on top of each other.",
|
|
103
|
+
"complexTypes": [
|
|
104
|
+
"MultiplePermissionStatusResult",
|
|
105
|
+
"MultiplePermissionOptions"
|
|
106
|
+
],
|
|
107
|
+
"slug": "requestmultiple"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "shouldShowRationale",
|
|
111
|
+
"signature": "(options: PermissionOptions) => Promise<ShouldShowRationaleResult>",
|
|
112
|
+
"parameters": [
|
|
113
|
+
{
|
|
114
|
+
"name": "options",
|
|
115
|
+
"docs": "",
|
|
116
|
+
"type": "PermissionOptions"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"returns": "Promise<ShouldShowRationaleResult>",
|
|
120
|
+
"tags": [
|
|
121
|
+
{
|
|
122
|
+
"name": "param",
|
|
123
|
+
"text": "options.permission Logical permission to inspect."
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"docs": "Whether Android should show a rationale before requesting again.\nReturns `{ shouldShow: false }` on iOS and web.",
|
|
127
|
+
"complexTypes": [
|
|
128
|
+
"ShouldShowRationaleResult",
|
|
129
|
+
"PermissionOptions"
|
|
130
|
+
],
|
|
131
|
+
"slug": "shouldshowrationale"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "openSettings",
|
|
135
|
+
"signature": "(options?: OpenSettingsOptions | undefined) => Promise<void>",
|
|
136
|
+
"parameters": [
|
|
137
|
+
{
|
|
138
|
+
"name": "options",
|
|
139
|
+
"docs": "",
|
|
140
|
+
"type": "OpenSettingsOptions | undefined"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"returns": "Promise<void>",
|
|
144
|
+
"tags": [
|
|
145
|
+
{
|
|
146
|
+
"name": "param",
|
|
147
|
+
"text": "options.type Settings destination. Defaults to `application`."
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"docs": "Open the application or notification settings screen.\nRejects on web with `UNIMPLEMENTED`.",
|
|
151
|
+
"complexTypes": [
|
|
152
|
+
"OpenSettingsOptions"
|
|
153
|
+
],
|
|
154
|
+
"slug": "opensettings"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "requestPreciseLocation",
|
|
158
|
+
"signature": "() => Promise<PermissionStatusResult>",
|
|
159
|
+
"parameters": [],
|
|
160
|
+
"returns": "Promise<PermissionStatusResult>",
|
|
161
|
+
"tags": [],
|
|
162
|
+
"docs": "Ask for precise location.\nOn iOS, requests temporary full accuracy when already authorized when-in-use.\nOn Android, requests `ACCESS_FINE_LOCATION`.\nOn web, returns the geolocation permission status after prompting when possible.",
|
|
163
|
+
"complexTypes": [
|
|
164
|
+
"PermissionStatusResult"
|
|
165
|
+
],
|
|
166
|
+
"slug": "requestpreciselocation"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "getPluginVersion",
|
|
170
|
+
"signature": "() => Promise<PluginVersionResult>",
|
|
171
|
+
"parameters": [],
|
|
172
|
+
"returns": "Promise<PluginVersionResult>",
|
|
173
|
+
"tags": [],
|
|
174
|
+
"docs": "Returns the platform implementation version marker.",
|
|
175
|
+
"complexTypes": [
|
|
176
|
+
"PluginVersionResult"
|
|
177
|
+
],
|
|
178
|
+
"slug": "getpluginversion"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"properties": []
|
|
182
|
+
},
|
|
183
|
+
"interfaces": [
|
|
184
|
+
{
|
|
185
|
+
"name": "PermissionStatusResult",
|
|
186
|
+
"slug": "permissionstatusresult",
|
|
187
|
+
"docs": "Result for a single permission status.",
|
|
188
|
+
"tags": [
|
|
189
|
+
{
|
|
190
|
+
"text": "8.0.0",
|
|
191
|
+
"name": "since"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"methods": [],
|
|
195
|
+
"properties": [
|
|
196
|
+
{
|
|
197
|
+
"name": "status",
|
|
198
|
+
"tags": [],
|
|
199
|
+
"docs": "Current status for the requested permission.",
|
|
200
|
+
"complexTypes": [
|
|
201
|
+
"AppPermissionState"
|
|
202
|
+
],
|
|
203
|
+
"type": "AppPermissionState"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "PermissionOptions",
|
|
209
|
+
"slug": "permissionoptions",
|
|
210
|
+
"docs": "Options for checking or requesting a single permission.",
|
|
211
|
+
"tags": [
|
|
212
|
+
{
|
|
213
|
+
"text": "8.0.0",
|
|
214
|
+
"name": "since"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"methods": [],
|
|
218
|
+
"properties": [
|
|
219
|
+
{
|
|
220
|
+
"name": "permission",
|
|
221
|
+
"tags": [],
|
|
222
|
+
"docs": "Permission to evaluate.",
|
|
223
|
+
"complexTypes": [
|
|
224
|
+
"PermissionName"
|
|
225
|
+
],
|
|
226
|
+
"type": "PermissionName"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "MultiplePermissionStatusResult",
|
|
232
|
+
"slug": "multiplepermissionstatusresult",
|
|
233
|
+
"docs": "Result for several permission statuses.",
|
|
234
|
+
"tags": [
|
|
235
|
+
{
|
|
236
|
+
"text": "8.0.0",
|
|
237
|
+
"name": "since"
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"methods": [],
|
|
241
|
+
"properties": [
|
|
242
|
+
{
|
|
243
|
+
"name": "statuses",
|
|
244
|
+
"tags": [],
|
|
245
|
+
"docs": "Map of permission name to status.",
|
|
246
|
+
"complexTypes": [
|
|
247
|
+
"Record",
|
|
248
|
+
"AppPermissionState"
|
|
249
|
+
],
|
|
250
|
+
"type": "Record<string, AppPermissionState>"
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"name": "MultiplePermissionOptions",
|
|
256
|
+
"slug": "multiplepermissionoptions",
|
|
257
|
+
"docs": "Options for checking or requesting several permissions.",
|
|
258
|
+
"tags": [
|
|
259
|
+
{
|
|
260
|
+
"text": "8.0.0",
|
|
261
|
+
"name": "since"
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
"methods": [],
|
|
265
|
+
"properties": [
|
|
266
|
+
{
|
|
267
|
+
"name": "permissions",
|
|
268
|
+
"tags": [],
|
|
269
|
+
"docs": "Permissions to evaluate in order.",
|
|
270
|
+
"complexTypes": [
|
|
271
|
+
"PermissionName"
|
|
272
|
+
],
|
|
273
|
+
"type": "PermissionName[]"
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "ShouldShowRationaleResult",
|
|
279
|
+
"slug": "shouldshowrationaleresult",
|
|
280
|
+
"docs": "Result for Android rationale checks.",
|
|
281
|
+
"tags": [
|
|
282
|
+
{
|
|
283
|
+
"text": "8.0.0",
|
|
284
|
+
"name": "since"
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"methods": [],
|
|
288
|
+
"properties": [
|
|
289
|
+
{
|
|
290
|
+
"name": "shouldShow",
|
|
291
|
+
"tags": [],
|
|
292
|
+
"docs": "True only when Android would show a rationale dialog before requesting again.\nAlways false on iOS and web.",
|
|
293
|
+
"complexTypes": [],
|
|
294
|
+
"type": "boolean"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"name": "OpenSettingsOptions",
|
|
300
|
+
"slug": "opensettingsoptions",
|
|
301
|
+
"docs": "Options for opening system settings.",
|
|
302
|
+
"tags": [
|
|
303
|
+
{
|
|
304
|
+
"text": "8.0.0",
|
|
305
|
+
"name": "since"
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"methods": [],
|
|
309
|
+
"properties": [
|
|
310
|
+
{
|
|
311
|
+
"name": "type",
|
|
312
|
+
"tags": [],
|
|
313
|
+
"docs": "Which settings screen to open. Defaults to `application`.",
|
|
314
|
+
"complexTypes": [
|
|
315
|
+
"SettingsType"
|
|
316
|
+
],
|
|
317
|
+
"type": "SettingsType"
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "PluginVersionResult",
|
|
323
|
+
"slug": "pluginversionresult",
|
|
324
|
+
"docs": "Plugin version payload.",
|
|
325
|
+
"tags": [
|
|
326
|
+
{
|
|
327
|
+
"text": "8.0.0",
|
|
328
|
+
"name": "since"
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
"methods": [],
|
|
332
|
+
"properties": [
|
|
333
|
+
{
|
|
334
|
+
"name": "version",
|
|
335
|
+
"tags": [],
|
|
336
|
+
"docs": "Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers).",
|
|
337
|
+
"complexTypes": [],
|
|
338
|
+
"type": "string"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"enums": [],
|
|
344
|
+
"typeAliases": [
|
|
345
|
+
{
|
|
346
|
+
"name": "AppPermissionState",
|
|
347
|
+
"slug": "apppermissionstate",
|
|
348
|
+
"docs": "Normalized permission status returned by every platform implementation.\n\n- `granted`: the user allowed full access.\n- `denied`: the user has not granted access yet, or Android can show a rationale.\n- `blocked`: the user denied access and the app cannot prompt again without settings.\n- `limited`: partial access (for example iOS limited photo library or reduced location accuracy).\n- `unavailable`: the permission is not supported on this platform or not declared in the app manifest.",
|
|
349
|
+
"types": [
|
|
350
|
+
{
|
|
351
|
+
"text": "'granted'",
|
|
352
|
+
"complexTypes": []
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"text": "'denied'",
|
|
356
|
+
"complexTypes": []
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"text": "'blocked'",
|
|
360
|
+
"complexTypes": []
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"text": "'limited'",
|
|
364
|
+
"complexTypes": []
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"text": "'unavailable'",
|
|
368
|
+
"complexTypes": []
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "PermissionName",
|
|
374
|
+
"slug": "permissionname",
|
|
375
|
+
"docs": "Logical permission identifiers shared across iOS, Android, and web.\n\nAndroid-only names include `activityRecognition`, `phone`, `sms`, `mediaAudio`, `mediaImages`, and `mediaVideo`.\niOS-only names include `reminders` and `appTrackingTransparency`.\nWeb supports a subset via browser APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`).\nOn web, `locationAlways` is an alias of foreground geolocation only; browsers do not expose background location permission.",
|
|
376
|
+
"types": [
|
|
377
|
+
{
|
|
378
|
+
"text": "'camera'",
|
|
379
|
+
"complexTypes": []
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"text": "'microphone'",
|
|
383
|
+
"complexTypes": []
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"text": "'photoLibrary'",
|
|
387
|
+
"complexTypes": []
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"text": "'photoLibraryAddOnly'",
|
|
391
|
+
"complexTypes": []
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"text": "'contacts'",
|
|
395
|
+
"complexTypes": []
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"text": "'calendar'",
|
|
399
|
+
"complexTypes": []
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"text": "'reminders'",
|
|
403
|
+
"complexTypes": []
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"text": "'locationWhenInUse'",
|
|
407
|
+
"complexTypes": []
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"text": "'locationAlways'",
|
|
411
|
+
"complexTypes": []
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"text": "'bluetooth'",
|
|
415
|
+
"complexTypes": []
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"text": "'motion'",
|
|
419
|
+
"complexTypes": []
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"text": "'notifications'",
|
|
423
|
+
"complexTypes": []
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"text": "'speechRecognition'",
|
|
427
|
+
"complexTypes": []
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"text": "'appTrackingTransparency'",
|
|
431
|
+
"complexTypes": []
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"text": "'activityRecognition'",
|
|
435
|
+
"complexTypes": []
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"text": "'phone'",
|
|
439
|
+
"complexTypes": []
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"text": "'sms'",
|
|
443
|
+
"complexTypes": []
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"text": "'mediaAudio'",
|
|
447
|
+
"complexTypes": []
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"text": "'mediaImages'",
|
|
451
|
+
"complexTypes": []
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"text": "'mediaVideo'",
|
|
455
|
+
"complexTypes": []
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"name": "Record",
|
|
461
|
+
"slug": "record",
|
|
462
|
+
"docs": "Construct a type with a set of properties K of type T",
|
|
463
|
+
"types": [
|
|
464
|
+
{
|
|
465
|
+
"text": "{\r\n [P in K]: T;\r\n}",
|
|
466
|
+
"complexTypes": [
|
|
467
|
+
"K",
|
|
468
|
+
"T"
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
]
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"name": "SettingsType",
|
|
475
|
+
"slug": "settingstype",
|
|
476
|
+
"docs": "Settings screen type for `openSettings`.",
|
|
477
|
+
"types": [
|
|
478
|
+
{
|
|
479
|
+
"text": "'application'",
|
|
480
|
+
"complexTypes": []
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"text": "'notifications'",
|
|
484
|
+
"complexTypes": []
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
],
|
|
489
|
+
"pluginConfigs": []
|
|
490
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized permission status returned by every platform implementation.
|
|
3
|
+
*
|
|
4
|
+
* - `granted`: the user allowed full access.
|
|
5
|
+
* - `denied`: the user has not granted access yet, or Android can show a rationale.
|
|
6
|
+
* - `blocked`: the user denied access and the app cannot prompt again without settings.
|
|
7
|
+
* - `limited`: partial access (for example iOS limited photo library or reduced location accuracy).
|
|
8
|
+
* - `unavailable`: the permission is not supported on this platform or not declared in the app manifest.
|
|
9
|
+
*/
|
|
10
|
+
export type AppPermissionState = 'granted' | 'denied' | 'blocked' | 'limited' | 'unavailable';
|
|
11
|
+
/**
|
|
12
|
+
* Logical permission identifiers shared across iOS, Android, and web.
|
|
13
|
+
*
|
|
14
|
+
* Android-only names include `activityRecognition`, `phone`, `sms`, `mediaAudio`, `mediaImages`, and `mediaVideo`.
|
|
15
|
+
* iOS-only names include `reminders` and `appTrackingTransparency`.
|
|
16
|
+
* Web supports a subset via browser APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`).
|
|
17
|
+
* On web, `locationAlways` is an alias of foreground geolocation only; browsers do not expose background location permission.
|
|
18
|
+
*/
|
|
19
|
+
export type PermissionName = 'camera' | 'microphone' | 'photoLibrary' | 'photoLibraryAddOnly' | 'contacts' | 'calendar' | 'reminders' | 'locationWhenInUse' | 'locationAlways' | 'bluetooth' | 'motion' | 'notifications' | 'speechRecognition' | 'appTrackingTransparency' | 'activityRecognition' | 'phone' | 'sms' | 'mediaAudio' | 'mediaImages' | 'mediaVideo';
|
|
20
|
+
/**
|
|
21
|
+
* Options for checking or requesting a single permission.
|
|
22
|
+
*
|
|
23
|
+
* @since 8.0.0
|
|
24
|
+
*/
|
|
25
|
+
export interface PermissionOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Permission to evaluate.
|
|
28
|
+
*/
|
|
29
|
+
permission: PermissionName;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result for a single permission status.
|
|
33
|
+
*
|
|
34
|
+
* @since 8.0.0
|
|
35
|
+
*/
|
|
36
|
+
export interface PermissionStatusResult {
|
|
37
|
+
/**
|
|
38
|
+
* Current status for the requested permission.
|
|
39
|
+
*/
|
|
40
|
+
status: AppPermissionState;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for checking or requesting several permissions.
|
|
44
|
+
*
|
|
45
|
+
* @since 8.0.0
|
|
46
|
+
*/
|
|
47
|
+
export interface MultiplePermissionOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Permissions to evaluate in order.
|
|
50
|
+
*/
|
|
51
|
+
permissions: PermissionName[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Result for several permission statuses.
|
|
55
|
+
*
|
|
56
|
+
* @since 8.0.0
|
|
57
|
+
*/
|
|
58
|
+
export interface MultiplePermissionStatusResult {
|
|
59
|
+
/**
|
|
60
|
+
* Map of permission name to status.
|
|
61
|
+
*/
|
|
62
|
+
statuses: Record<string, AppPermissionState>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Result for Android rationale checks.
|
|
66
|
+
*
|
|
67
|
+
* @since 8.0.0
|
|
68
|
+
*/
|
|
69
|
+
export interface ShouldShowRationaleResult {
|
|
70
|
+
/**
|
|
71
|
+
* True only when Android would show a rationale dialog before requesting again.
|
|
72
|
+
* Always false on iOS and web.
|
|
73
|
+
*/
|
|
74
|
+
shouldShow: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Settings screen type for `openSettings`.
|
|
78
|
+
*
|
|
79
|
+
* @since 8.0.0
|
|
80
|
+
*/
|
|
81
|
+
export type SettingsType = 'application' | 'notifications';
|
|
82
|
+
/**
|
|
83
|
+
* Options for opening system settings.
|
|
84
|
+
*
|
|
85
|
+
* @since 8.0.0
|
|
86
|
+
*/
|
|
87
|
+
export interface OpenSettingsOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Which settings screen to open. Defaults to `application`.
|
|
90
|
+
*/
|
|
91
|
+
type?: SettingsType;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Plugin version payload.
|
|
95
|
+
*
|
|
96
|
+
* @since 8.0.0
|
|
97
|
+
*/
|
|
98
|
+
export interface PluginVersionResult {
|
|
99
|
+
/**
|
|
100
|
+
* Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers).
|
|
101
|
+
*/
|
|
102
|
+
version: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Cross-platform permissions API for Capacitor apps.
|
|
106
|
+
*
|
|
107
|
+
* @since 8.0.0
|
|
108
|
+
*/
|
|
109
|
+
export interface PermissionsPlugin {
|
|
110
|
+
/**
|
|
111
|
+
* Check the current status of one permission without prompting the user.
|
|
112
|
+
*
|
|
113
|
+
* @param options.permission Logical permission to inspect.
|
|
114
|
+
*/
|
|
115
|
+
check(options: PermissionOptions): Promise<PermissionStatusResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Request one permission from the user. On Android, shows the system dialog when needed.
|
|
118
|
+
*
|
|
119
|
+
* @param options.permission Logical permission to request.
|
|
120
|
+
*/
|
|
121
|
+
request(options: PermissionOptions): Promise<PermissionStatusResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Check several permissions without prompting.
|
|
124
|
+
*
|
|
125
|
+
* @param options.permissions List of permissions to inspect.
|
|
126
|
+
*/
|
|
127
|
+
checkMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Request several permissions sequentially so dialogs are not shown on top of each other.
|
|
130
|
+
*
|
|
131
|
+
* @param options.permissions List of permissions to request.
|
|
132
|
+
*/
|
|
133
|
+
requestMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Whether Android should show a rationale before requesting again.
|
|
136
|
+
* Returns `{ shouldShow: false }` on iOS and web.
|
|
137
|
+
*
|
|
138
|
+
* @param options.permission Logical permission to inspect.
|
|
139
|
+
*/
|
|
140
|
+
shouldShowRationale(options: PermissionOptions): Promise<ShouldShowRationaleResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Open the application or notification settings screen.
|
|
143
|
+
* Rejects on web with `UNIMPLEMENTED`.
|
|
144
|
+
*
|
|
145
|
+
* @param options.type Settings destination. Defaults to `application`.
|
|
146
|
+
*/
|
|
147
|
+
openSettings(options?: OpenSettingsOptions): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Ask for precise location.
|
|
150
|
+
* On iOS, requests temporary full accuracy when already authorized when-in-use.
|
|
151
|
+
* On Android, requests `ACCESS_FINE_LOCATION`.
|
|
152
|
+
* On web, returns the geolocation permission status after prompting when possible.
|
|
153
|
+
*/
|
|
154
|
+
requestPreciseLocation(): Promise<PermissionStatusResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the platform implementation version marker.
|
|
157
|
+
*/
|
|
158
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Normalized permission status returned by every platform implementation.\n *\n * - `granted`: the user allowed full access.\n * - `denied`: the user has not granted access yet, or Android can show a rationale.\n * - `blocked`: the user denied access and the app cannot prompt again without settings.\n * - `limited`: partial access (for example iOS limited photo library or reduced location accuracy).\n * - `unavailable`: the permission is not supported on this platform or not declared in the app manifest.\n */\nexport type AppPermissionState = 'granted' | 'denied' | 'blocked' | 'limited' | 'unavailable';\n\n/**\n * Logical permission identifiers shared across iOS, Android, and web.\n *\n * Android-only names include `activityRecognition`, `phone`, `sms`, `mediaAudio`, `mediaImages`, and `mediaVideo`.\n * iOS-only names include `reminders` and `appTrackingTransparency`.\n * Web supports a subset via browser APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`).\n * On web, `locationAlways` is an alias of foreground geolocation only; browsers do not expose background location permission.\n */\nexport type PermissionName =\n | 'camera'\n | 'microphone'\n | 'photoLibrary'\n | 'photoLibraryAddOnly'\n | 'contacts'\n | 'calendar'\n | 'reminders'\n | 'locationWhenInUse'\n | 'locationAlways'\n | 'bluetooth'\n | 'motion'\n | 'notifications'\n | 'speechRecognition'\n | 'appTrackingTransparency'\n | 'activityRecognition'\n | 'phone'\n | 'sms'\n | 'mediaAudio'\n | 'mediaImages'\n | 'mediaVideo';\n\n/**\n * Options for checking or requesting a single permission.\n *\n * @since 8.0.0\n */\nexport interface PermissionOptions {\n /**\n * Permission to evaluate.\n */\n permission: PermissionName;\n}\n\n/**\n * Result for a single permission status.\n *\n * @since 8.0.0\n */\nexport interface PermissionStatusResult {\n /**\n * Current status for the requested permission.\n */\n status: AppPermissionState;\n}\n\n/**\n * Options for checking or requesting several permissions.\n *\n * @since 8.0.0\n */\nexport interface MultiplePermissionOptions {\n /**\n * Permissions to evaluate in order.\n */\n permissions: PermissionName[];\n}\n\n/**\n * Result for several permission statuses.\n *\n * @since 8.0.0\n */\nexport interface MultiplePermissionStatusResult {\n /**\n * Map of permission name to status.\n */\n statuses: Record<string, AppPermissionState>;\n}\n\n/**\n * Result for Android rationale checks.\n *\n * @since 8.0.0\n */\nexport interface ShouldShowRationaleResult {\n /**\n * True only when Android would show a rationale dialog before requesting again.\n * Always false on iOS and web.\n */\n shouldShow: boolean;\n}\n\n/**\n * Settings screen type for `openSettings`.\n *\n * @since 8.0.0\n */\nexport type SettingsType = 'application' | 'notifications';\n\n/**\n * Options for opening system settings.\n *\n * @since 8.0.0\n */\nexport interface OpenSettingsOptions {\n /**\n * Which settings screen to open. Defaults to `application`.\n */\n type?: SettingsType;\n}\n\n/**\n * Plugin version payload.\n *\n * @since 8.0.0\n */\nexport interface PluginVersionResult {\n /**\n * Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers).\n */\n version: string;\n}\n\n/**\n * Cross-platform permissions API for Capacitor apps.\n *\n * @since 8.0.0\n */\nexport interface PermissionsPlugin {\n /**\n * Check the current status of one permission without prompting the user.\n *\n * @param options.permission Logical permission to inspect.\n */\n check(options: PermissionOptions): Promise<PermissionStatusResult>;\n\n /**\n * Request one permission from the user. On Android, shows the system dialog when needed.\n *\n * @param options.permission Logical permission to request.\n */\n request(options: PermissionOptions): Promise<PermissionStatusResult>;\n\n /**\n * Check several permissions without prompting.\n *\n * @param options.permissions List of permissions to inspect.\n */\n checkMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;\n\n /**\n * Request several permissions sequentially so dialogs are not shown on top of each other.\n *\n * @param options.permissions List of permissions to request.\n */\n requestMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;\n\n /**\n * Whether Android should show a rationale before requesting again.\n * Returns `{ shouldShow: false }` on iOS and web.\n *\n * @param options.permission Logical permission to inspect.\n */\n shouldShowRationale(options: PermissionOptions): Promise<ShouldShowRationaleResult>;\n\n /**\n * Open the application or notification settings screen.\n * Rejects on web with `UNIMPLEMENTED`.\n *\n * @param options.type Settings destination. Defaults to `application`.\n */\n openSettings(options?: OpenSettingsOptions): Promise<void>;\n\n /**\n * Ask for precise location.\n * On iOS, requests temporary full accuracy when already authorized when-in-use.\n * On Android, requests `ACCESS_FINE_LOCATION`.\n * On web, returns the geolocation permission status after prompting when possible.\n */\n requestPreciseLocation(): Promise<PermissionStatusResult>;\n\n /**\n * Returns the platform implementation version marker.\n */\n getPluginVersion(): Promise<PluginVersionResult>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const Permissions = registerPlugin('Permissions', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.PermissionsWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { Permissions };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACnE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { PermissionsPlugin } from './definitions';\n\nconst Permissions = registerPlugin<PermissionsPlugin>('Permissions', {\n web: () => import('./web').then((m) => new m.PermissionsWeb()),\n});\n\nexport * from './definitions';\nexport type { AppPermissionState as PermissionState } from './definitions';\nexport { Permissions };\n"]}
|