@capgo/capacitor-permissions 8.2.1 → 8.2.3
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/README.md +44 -21
- package/dist/docs.json +111 -14
- package/dist/esm/definitions.d.ts +64 -4
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
- Request notification permission before registering push tokens
|
|
28
28
|
- Upgrade from reduced to precise location when a map feature needs it
|
|
29
29
|
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
- [Plugin docs on Capgo](https://capgo.app/docs/plugins/permissions/)
|
|
33
|
+
- [Tutorial: capacitor-permissions](https://capgo.app/plugins/capacitor-permissions/)
|
|
34
|
+
- [Capgo live updates](https://capgo.app/?ref=plugin_permissions)
|
|
35
|
+
|
|
30
36
|
<p align="center">
|
|
31
37
|
<img src="./screenshots/android-request.webp" alt="Android emulator showing the camera permission dialog" width="280" />
|
|
32
38
|
<img src="./screenshots/android-granted.webp" alt="Example app reporting camera permission as granted" width="280" />
|
|
@@ -207,6 +213,8 @@ Check the current status of one permission without prompting the user.
|
|
|
207
213
|
|
|
208
214
|
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
209
215
|
|
|
216
|
+
**Since:** 8.0.0
|
|
217
|
+
|
|
210
218
|
--------------------
|
|
211
219
|
|
|
212
220
|
|
|
@@ -217,6 +225,7 @@ request(options: PermissionOptions) => Promise<PermissionStatusResult>
|
|
|
217
225
|
```
|
|
218
226
|
|
|
219
227
|
Request one permission from the user. On Android, shows the system dialog when needed.
|
|
228
|
+
On iOS, triggers the platform authorization flow for the mapped capability.
|
|
220
229
|
|
|
221
230
|
| Param | Type |
|
|
222
231
|
| ------------- | --------------------------------------------------------------- |
|
|
@@ -224,6 +233,8 @@ Request one permission from the user. On Android, shows the system dialog when n
|
|
|
224
233
|
|
|
225
234
|
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
226
235
|
|
|
236
|
+
**Since:** 8.0.0
|
|
237
|
+
|
|
227
238
|
--------------------
|
|
228
239
|
|
|
229
240
|
|
|
@@ -241,6 +252,8 @@ Check several permissions without prompting.
|
|
|
241
252
|
|
|
242
253
|
**Returns:** <code>Promise<<a href="#multiplepermissionstatusresult">MultiplePermissionStatusResult</a>></code>
|
|
243
254
|
|
|
255
|
+
**Since:** 8.0.0
|
|
256
|
+
|
|
244
257
|
--------------------
|
|
245
258
|
|
|
246
259
|
|
|
@@ -258,6 +271,8 @@ Request several permissions sequentially so dialogs are not shown on top of each
|
|
|
258
271
|
|
|
259
272
|
**Returns:** <code>Promise<<a href="#multiplepermissionstatusresult">MultiplePermissionStatusResult</a>></code>
|
|
260
273
|
|
|
274
|
+
**Since:** 8.0.0
|
|
275
|
+
|
|
261
276
|
--------------------
|
|
262
277
|
|
|
263
278
|
|
|
@@ -276,6 +291,8 @@ Returns `{ shouldShow: false }` on iOS and web.
|
|
|
276
291
|
|
|
277
292
|
**Returns:** <code>Promise<<a href="#shouldshowrationaleresult">ShouldShowRationaleResult</a>></code>
|
|
278
293
|
|
|
294
|
+
**Since:** 8.0.0
|
|
295
|
+
|
|
279
296
|
--------------------
|
|
280
297
|
|
|
281
298
|
|
|
@@ -292,6 +309,8 @@ Rejects on web with `UNIMPLEMENTED`.
|
|
|
292
309
|
| ------------- | ------------------------------------------------------------------- |
|
|
293
310
|
| **`options`** | <code><a href="#opensettingsoptions">OpenSettingsOptions</a></code> |
|
|
294
311
|
|
|
312
|
+
**Since:** 8.0.0
|
|
313
|
+
|
|
295
314
|
--------------------
|
|
296
315
|
|
|
297
316
|
|
|
@@ -308,6 +327,8 @@ On web, returns the geolocation permission status after prompting when possible.
|
|
|
308
327
|
|
|
309
328
|
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
310
329
|
|
|
330
|
+
**Since:** 8.0.0
|
|
331
|
+
|
|
311
332
|
--------------------
|
|
312
333
|
|
|
313
334
|
|
|
@@ -321,6 +342,8 @@ Returns the platform implementation version marker.
|
|
|
321
342
|
|
|
322
343
|
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
323
344
|
|
|
345
|
+
**Since:** 8.0.0
|
|
346
|
+
|
|
324
347
|
--------------------
|
|
325
348
|
|
|
326
349
|
|
|
@@ -331,63 +354,63 @@ Returns the platform implementation version marker.
|
|
|
331
354
|
|
|
332
355
|
Result for a single permission status.
|
|
333
356
|
|
|
334
|
-
| Prop | Type | Description |
|
|
335
|
-
| ------------ | ----------------------------------------------------------------- | -------------------------------------------- |
|
|
336
|
-
| **`status`** | <code><a href="#apppermissionstate">AppPermissionState</a></code> | Current status for the requested permission. |
|
|
357
|
+
| Prop | Type | Description | Since |
|
|
358
|
+
| ------------ | ----------------------------------------------------------------- | -------------------------------------------- | ----- |
|
|
359
|
+
| **`status`** | <code><a href="#apppermissionstate">AppPermissionState</a></code> | Current status for the requested permission. | 8.0.0 |
|
|
337
360
|
|
|
338
361
|
|
|
339
362
|
#### PermissionOptions
|
|
340
363
|
|
|
341
364
|
Options for checking or requesting a single permission.
|
|
342
365
|
|
|
343
|
-
| Prop | Type | Description
|
|
344
|
-
| ---------------- | --------------------------------------------------------- |
|
|
345
|
-
| **`permission`** | <code><a href="#permissionname">PermissionName</a></code> |
|
|
366
|
+
| Prop | Type | Description | Since |
|
|
367
|
+
| ---------------- | --------------------------------------------------------- | ------------------------------------------ | ----- |
|
|
368
|
+
| **`permission`** | <code><a href="#permissionname">PermissionName</a></code> | Logical permission to evaluate or request. | 8.0.0 |
|
|
346
369
|
|
|
347
370
|
|
|
348
371
|
#### MultiplePermissionStatusResult
|
|
349
372
|
|
|
350
373
|
Result for several permission statuses.
|
|
351
374
|
|
|
352
|
-
| Prop | Type | Description
|
|
353
|
-
| -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
354
|
-
| **`statuses`** | <code><a href="#record">Record</a><string, <a href="#apppermissionstate">AppPermissionState</a>></code> | Map of permission name to status. |
|
|
375
|
+
| Prop | Type | Description | Since |
|
|
376
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ----- |
|
|
377
|
+
| **`statuses`** | <code><a href="#record">Record</a><string, <a href="#apppermissionstate">AppPermissionState</a>></code> | Map of permission name to status. Keys match the names passed in `permissions`. | 8.0.0 |
|
|
355
378
|
|
|
356
379
|
|
|
357
380
|
#### MultiplePermissionOptions
|
|
358
381
|
|
|
359
382
|
Options for checking or requesting several permissions.
|
|
360
383
|
|
|
361
|
-
| Prop | Type | Description
|
|
362
|
-
| ----------------- | ----------------------------- |
|
|
363
|
-
| **`permissions`** | <code>PermissionName[]</code> | Permissions to evaluate in order. |
|
|
384
|
+
| Prop | Type | Description | Since |
|
|
385
|
+
| ----------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------- | ----- |
|
|
386
|
+
| **`permissions`** | <code>PermissionName[]</code> | Permissions to evaluate in order. On `requestMultiple`, each permission is requested one after another. | 8.0.0 |
|
|
364
387
|
|
|
365
388
|
|
|
366
389
|
#### ShouldShowRationaleResult
|
|
367
390
|
|
|
368
391
|
Result for Android rationale checks.
|
|
369
392
|
|
|
370
|
-
| Prop | Type | Description |
|
|
371
|
-
| ---------------- | -------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
372
|
-
| **`shouldShow`** | <code>boolean</code> | True only when Android would show a rationale dialog before requesting again. Always false on iOS and web. |
|
|
393
|
+
| Prop | Type | Description | Since |
|
|
394
|
+
| ---------------- | -------------------- | ---------------------------------------------------------------------------------------------------------- | ----- |
|
|
395
|
+
| **`shouldShow`** | <code>boolean</code> | True only when Android would show a rationale dialog before requesting again. Always false on iOS and web. | 8.0.0 |
|
|
373
396
|
|
|
374
397
|
|
|
375
398
|
#### OpenSettingsOptions
|
|
376
399
|
|
|
377
400
|
Options for opening system settings.
|
|
378
401
|
|
|
379
|
-
| Prop | Type | Description
|
|
380
|
-
| ---------- | ----------------------------------------------------- |
|
|
381
|
-
| **`type`** | <code><a href="#settingstype">SettingsType</a></code> | Which settings screen to open.
|
|
402
|
+
| Prop | Type | Description | Default | Since |
|
|
403
|
+
| ---------- | ----------------------------------------------------- | ------------------------------ | -------------------------- | ----- |
|
|
404
|
+
| **`type`** | <code><a href="#settingstype">SettingsType</a></code> | Which settings screen to open. | <code>'application'</code> | 8.0.0 |
|
|
382
405
|
|
|
383
406
|
|
|
384
407
|
#### PluginVersionResult
|
|
385
408
|
|
|
386
409
|
Plugin version payload.
|
|
387
410
|
|
|
388
|
-
| Prop | Type | Description |
|
|
389
|
-
| ------------- | ------------------- | --------------------------------------------------------------------------------------------------- |
|
|
390
|
-
| **`version`** | <code>string</code> | Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers). |
|
|
411
|
+
| Prop | Type | Description | Since |
|
|
412
|
+
| ------------- | ------------------- | --------------------------------------------------------------------------------------------------- | ----- |
|
|
413
|
+
| **`version`** | <code>string</code> | Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers). | 8.0.0 |
|
|
391
414
|
|
|
392
415
|
|
|
393
416
|
### Type Aliases
|
package/dist/docs.json
CHANGED
|
@@ -25,6 +25,14 @@
|
|
|
25
25
|
{
|
|
26
26
|
"name": "param",
|
|
27
27
|
"text": "options.permission Logical permission to inspect."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "since",
|
|
31
|
+
"text": "8.0.0"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "example",
|
|
35
|
+
"text": "```typescript\nconst { status } = await Permissions.check({ permission: 'camera' });\n```"
|
|
28
36
|
}
|
|
29
37
|
],
|
|
30
38
|
"docs": "Check the current status of one permission without prompting the user.",
|
|
@@ -49,9 +57,17 @@
|
|
|
49
57
|
{
|
|
50
58
|
"name": "param",
|
|
51
59
|
"text": "options.permission Logical permission to request."
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "since",
|
|
63
|
+
"text": "8.0.0"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "example",
|
|
67
|
+
"text": "```typescript\nconst { status } = await Permissions.request({ permission: 'notifications' });\n```"
|
|
52
68
|
}
|
|
53
69
|
],
|
|
54
|
-
"docs": "Request one permission from the user. On Android, shows the system dialog when needed.",
|
|
70
|
+
"docs": "Request one permission from the user. On Android, shows the system dialog when needed.\nOn iOS, triggers the platform authorization flow for the mapped capability.",
|
|
55
71
|
"complexTypes": [
|
|
56
72
|
"PermissionStatusResult",
|
|
57
73
|
"PermissionOptions"
|
|
@@ -73,6 +89,14 @@
|
|
|
73
89
|
{
|
|
74
90
|
"name": "param",
|
|
75
91
|
"text": "options.permissions List of permissions to inspect."
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "since",
|
|
95
|
+
"text": "8.0.0"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "example",
|
|
99
|
+
"text": "```typescript\nconst { statuses } = await Permissions.checkMultiple({\n permissions: ['camera', 'microphone'],\n});\n```"
|
|
76
100
|
}
|
|
77
101
|
],
|
|
78
102
|
"docs": "Check several permissions without prompting.",
|
|
@@ -97,6 +121,10 @@
|
|
|
97
121
|
{
|
|
98
122
|
"name": "param",
|
|
99
123
|
"text": "options.permissions List of permissions to request."
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "since",
|
|
127
|
+
"text": "8.0.0"
|
|
100
128
|
}
|
|
101
129
|
],
|
|
102
130
|
"docs": "Request several permissions sequentially so dialogs are not shown on top of each other.",
|
|
@@ -121,6 +149,14 @@
|
|
|
121
149
|
{
|
|
122
150
|
"name": "param",
|
|
123
151
|
"text": "options.permission Logical permission to inspect."
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "since",
|
|
155
|
+
"text": "8.0.0"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "example",
|
|
159
|
+
"text": "```typescript\nconst { shouldShow } = await Permissions.shouldShowRationale({ permission: 'camera' });\nif (shouldShow) {\n await showWhyWeNeedCamera();\n await Permissions.request({ permission: 'camera' });\n}\n```"
|
|
124
160
|
}
|
|
125
161
|
],
|
|
126
162
|
"docs": "Whether Android should show a rationale before requesting again.\nReturns `{ shouldShow: false }` on iOS and web.",
|
|
@@ -145,6 +181,14 @@
|
|
|
145
181
|
{
|
|
146
182
|
"name": "param",
|
|
147
183
|
"text": "options.type Settings destination. Defaults to `application`."
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "since",
|
|
187
|
+
"text": "8.0.0"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "example",
|
|
191
|
+
"text": "```typescript\nawait Permissions.openSettings({ type: 'notifications' });\n```"
|
|
148
192
|
}
|
|
149
193
|
],
|
|
150
194
|
"docs": "Open the application or notification settings screen.\nRejects on web with `UNIMPLEMENTED`.",
|
|
@@ -158,7 +202,16 @@
|
|
|
158
202
|
"signature": "() => Promise<PermissionStatusResult>",
|
|
159
203
|
"parameters": [],
|
|
160
204
|
"returns": "Promise<PermissionStatusResult>",
|
|
161
|
-
"tags": [
|
|
205
|
+
"tags": [
|
|
206
|
+
{
|
|
207
|
+
"name": "since",
|
|
208
|
+
"text": "8.0.0"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "example",
|
|
212
|
+
"text": "```typescript\nconst { status } = await Permissions.requestPreciseLocation();\n```"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
162
215
|
"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
216
|
"complexTypes": [
|
|
164
217
|
"PermissionStatusResult"
|
|
@@ -170,7 +223,12 @@
|
|
|
170
223
|
"signature": "() => Promise<PluginVersionResult>",
|
|
171
224
|
"parameters": [],
|
|
172
225
|
"returns": "Promise<PluginVersionResult>",
|
|
173
|
-
"tags": [
|
|
226
|
+
"tags": [
|
|
227
|
+
{
|
|
228
|
+
"name": "since",
|
|
229
|
+
"text": "8.0.0"
|
|
230
|
+
}
|
|
231
|
+
],
|
|
174
232
|
"docs": "Returns the platform implementation version marker.",
|
|
175
233
|
"complexTypes": [
|
|
176
234
|
"PluginVersionResult"
|
|
@@ -195,7 +253,12 @@
|
|
|
195
253
|
"properties": [
|
|
196
254
|
{
|
|
197
255
|
"name": "status",
|
|
198
|
-
"tags": [
|
|
256
|
+
"tags": [
|
|
257
|
+
{
|
|
258
|
+
"text": "8.0.0",
|
|
259
|
+
"name": "since"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
199
262
|
"docs": "Current status for the requested permission.",
|
|
200
263
|
"complexTypes": [
|
|
201
264
|
"AppPermissionState"
|
|
@@ -218,8 +281,13 @@
|
|
|
218
281
|
"properties": [
|
|
219
282
|
{
|
|
220
283
|
"name": "permission",
|
|
221
|
-
"tags": [
|
|
222
|
-
|
|
284
|
+
"tags": [
|
|
285
|
+
{
|
|
286
|
+
"text": "8.0.0",
|
|
287
|
+
"name": "since"
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
"docs": "Logical permission to evaluate or request.",
|
|
223
291
|
"complexTypes": [
|
|
224
292
|
"PermissionName"
|
|
225
293
|
],
|
|
@@ -241,8 +309,13 @@
|
|
|
241
309
|
"properties": [
|
|
242
310
|
{
|
|
243
311
|
"name": "statuses",
|
|
244
|
-
"tags": [
|
|
245
|
-
|
|
312
|
+
"tags": [
|
|
313
|
+
{
|
|
314
|
+
"text": "8.0.0",
|
|
315
|
+
"name": "since"
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
"docs": "Map of permission name to status. Keys match the names passed in `permissions`.",
|
|
246
319
|
"complexTypes": [
|
|
247
320
|
"Record",
|
|
248
321
|
"AppPermissionState"
|
|
@@ -265,8 +338,13 @@
|
|
|
265
338
|
"properties": [
|
|
266
339
|
{
|
|
267
340
|
"name": "permissions",
|
|
268
|
-
"tags": [
|
|
269
|
-
|
|
341
|
+
"tags": [
|
|
342
|
+
{
|
|
343
|
+
"text": "8.0.0",
|
|
344
|
+
"name": "since"
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"docs": "Permissions to evaluate in order. On `requestMultiple`, each permission is requested one after another.",
|
|
270
348
|
"complexTypes": [
|
|
271
349
|
"PermissionName"
|
|
272
350
|
],
|
|
@@ -288,7 +366,12 @@
|
|
|
288
366
|
"properties": [
|
|
289
367
|
{
|
|
290
368
|
"name": "shouldShow",
|
|
291
|
-
"tags": [
|
|
369
|
+
"tags": [
|
|
370
|
+
{
|
|
371
|
+
"text": "8.0.0",
|
|
372
|
+
"name": "since"
|
|
373
|
+
}
|
|
374
|
+
],
|
|
292
375
|
"docs": "True only when Android would show a rationale dialog before requesting again.\nAlways false on iOS and web.",
|
|
293
376
|
"complexTypes": [],
|
|
294
377
|
"type": "boolean"
|
|
@@ -309,8 +392,17 @@
|
|
|
309
392
|
"properties": [
|
|
310
393
|
{
|
|
311
394
|
"name": "type",
|
|
312
|
-
"tags": [
|
|
313
|
-
|
|
395
|
+
"tags": [
|
|
396
|
+
{
|
|
397
|
+
"text": "'application'",
|
|
398
|
+
"name": "default"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"text": "8.0.0",
|
|
402
|
+
"name": "since"
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
"docs": "Which settings screen to open.",
|
|
314
406
|
"complexTypes": [
|
|
315
407
|
"SettingsType"
|
|
316
408
|
],
|
|
@@ -332,7 +424,12 @@
|
|
|
332
424
|
"properties": [
|
|
333
425
|
{
|
|
334
426
|
"name": "version",
|
|
335
|
-
"tags": [
|
|
427
|
+
"tags": [
|
|
428
|
+
{
|
|
429
|
+
"text": "8.0.0",
|
|
430
|
+
"name": "since"
|
|
431
|
+
}
|
|
432
|
+
],
|
|
336
433
|
"docs": "Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers).",
|
|
337
434
|
"complexTypes": [],
|
|
338
435
|
"type": "string"
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - `blocked`: the user denied access and the app cannot prompt again without settings.
|
|
7
7
|
* - `limited`: partial access (for example iOS limited photo library or reduced location accuracy).
|
|
8
8
|
* - `unavailable`: the permission is not supported on this platform or not declared in the app manifest.
|
|
9
|
+
*
|
|
10
|
+
* @since 8.0.0
|
|
9
11
|
*/
|
|
10
12
|
export type AppPermissionState = 'granted' | 'denied' | 'blocked' | 'limited' | 'unavailable';
|
|
11
13
|
/**
|
|
@@ -15,6 +17,8 @@ export type AppPermissionState = 'granted' | 'denied' | 'blocked' | 'limited' |
|
|
|
15
17
|
* iOS-only names include `reminders` and `appTrackingTransparency`.
|
|
16
18
|
* Web supports a subset via browser APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`).
|
|
17
19
|
* On web, `locationAlways` is an alias of foreground geolocation only; browsers do not expose background location permission.
|
|
20
|
+
*
|
|
21
|
+
* @since 8.0.0
|
|
18
22
|
*/
|
|
19
23
|
export type PermissionName = 'camera' | 'microphone' | 'photoLibrary' | 'photoLibraryAddOnly' | 'contacts' | 'calendar' | 'reminders' | 'locationWhenInUse' | 'locationAlways' | 'bluetooth' | 'motion' | 'notifications' | 'speechRecognition' | 'appTrackingTransparency' | 'activityRecognition' | 'phone' | 'sms' | 'mediaAudio' | 'mediaImages' | 'mediaVideo';
|
|
20
24
|
/**
|
|
@@ -24,7 +28,9 @@ export type PermissionName = 'camera' | 'microphone' | 'photoLibrary' | 'photoLi
|
|
|
24
28
|
*/
|
|
25
29
|
export interface PermissionOptions {
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Logical permission to evaluate or request.
|
|
32
|
+
*
|
|
33
|
+
* @since 8.0.0
|
|
28
34
|
*/
|
|
29
35
|
permission: PermissionName;
|
|
30
36
|
}
|
|
@@ -36,6 +42,8 @@ export interface PermissionOptions {
|
|
|
36
42
|
export interface PermissionStatusResult {
|
|
37
43
|
/**
|
|
38
44
|
* Current status for the requested permission.
|
|
45
|
+
*
|
|
46
|
+
* @since 8.0.0
|
|
39
47
|
*/
|
|
40
48
|
status: AppPermissionState;
|
|
41
49
|
}
|
|
@@ -46,7 +54,9 @@ export interface PermissionStatusResult {
|
|
|
46
54
|
*/
|
|
47
55
|
export interface MultiplePermissionOptions {
|
|
48
56
|
/**
|
|
49
|
-
* Permissions to evaluate in order.
|
|
57
|
+
* Permissions to evaluate in order. On `requestMultiple`, each permission is requested one after another.
|
|
58
|
+
*
|
|
59
|
+
* @since 8.0.0
|
|
50
60
|
*/
|
|
51
61
|
permissions: PermissionName[];
|
|
52
62
|
}
|
|
@@ -57,7 +67,9 @@ export interface MultiplePermissionOptions {
|
|
|
57
67
|
*/
|
|
58
68
|
export interface MultiplePermissionStatusResult {
|
|
59
69
|
/**
|
|
60
|
-
* Map of permission name to status.
|
|
70
|
+
* Map of permission name to status. Keys match the names passed in `permissions`.
|
|
71
|
+
*
|
|
72
|
+
* @since 8.0.0
|
|
61
73
|
*/
|
|
62
74
|
statuses: Record<string, AppPermissionState>;
|
|
63
75
|
}
|
|
@@ -70,6 +82,8 @@ export interface ShouldShowRationaleResult {
|
|
|
70
82
|
/**
|
|
71
83
|
* True only when Android would show a rationale dialog before requesting again.
|
|
72
84
|
* Always false on iOS and web.
|
|
85
|
+
*
|
|
86
|
+
* @since 8.0.0
|
|
73
87
|
*/
|
|
74
88
|
shouldShow: boolean;
|
|
75
89
|
}
|
|
@@ -86,7 +100,10 @@ export type SettingsType = 'application' | 'notifications';
|
|
|
86
100
|
*/
|
|
87
101
|
export interface OpenSettingsOptions {
|
|
88
102
|
/**
|
|
89
|
-
* Which settings screen to open.
|
|
103
|
+
* Which settings screen to open.
|
|
104
|
+
*
|
|
105
|
+
* @default 'application'
|
|
106
|
+
* @since 8.0.0
|
|
90
107
|
*/
|
|
91
108
|
type?: SettingsType;
|
|
92
109
|
}
|
|
@@ -98,6 +115,8 @@ export interface OpenSettingsOptions {
|
|
|
98
115
|
export interface PluginVersionResult {
|
|
99
116
|
/**
|
|
100
117
|
* Version identifier returned by the platform implementation (`native` on mobile, `web` in browsers).
|
|
118
|
+
*
|
|
119
|
+
* @since 8.0.0
|
|
101
120
|
*/
|
|
102
121
|
version: string;
|
|
103
122
|
}
|
|
@@ -111,24 +130,43 @@ export interface PermissionsPlugin {
|
|
|
111
130
|
* Check the current status of one permission without prompting the user.
|
|
112
131
|
*
|
|
113
132
|
* @param options.permission Logical permission to inspect.
|
|
133
|
+
* @since 8.0.0
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const { status } = await Permissions.check({ permission: 'camera' });
|
|
137
|
+
* ```
|
|
114
138
|
*/
|
|
115
139
|
check(options: PermissionOptions): Promise<PermissionStatusResult>;
|
|
116
140
|
/**
|
|
117
141
|
* Request one permission from the user. On Android, shows the system dialog when needed.
|
|
142
|
+
* On iOS, triggers the platform authorization flow for the mapped capability.
|
|
118
143
|
*
|
|
119
144
|
* @param options.permission Logical permission to request.
|
|
145
|
+
* @since 8.0.0
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const { status } = await Permissions.request({ permission: 'notifications' });
|
|
149
|
+
* ```
|
|
120
150
|
*/
|
|
121
151
|
request(options: PermissionOptions): Promise<PermissionStatusResult>;
|
|
122
152
|
/**
|
|
123
153
|
* Check several permissions without prompting.
|
|
124
154
|
*
|
|
125
155
|
* @param options.permissions List of permissions to inspect.
|
|
156
|
+
* @since 8.0.0
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const { statuses } = await Permissions.checkMultiple({
|
|
160
|
+
* permissions: ['camera', 'microphone'],
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
126
163
|
*/
|
|
127
164
|
checkMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;
|
|
128
165
|
/**
|
|
129
166
|
* Request several permissions sequentially so dialogs are not shown on top of each other.
|
|
130
167
|
*
|
|
131
168
|
* @param options.permissions List of permissions to request.
|
|
169
|
+
* @since 8.0.0
|
|
132
170
|
*/
|
|
133
171
|
requestMultiple(options: MultiplePermissionOptions): Promise<MultiplePermissionStatusResult>;
|
|
134
172
|
/**
|
|
@@ -136,6 +174,15 @@ export interface PermissionsPlugin {
|
|
|
136
174
|
* Returns `{ shouldShow: false }` on iOS and web.
|
|
137
175
|
*
|
|
138
176
|
* @param options.permission Logical permission to inspect.
|
|
177
|
+
* @since 8.0.0
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const { shouldShow } = await Permissions.shouldShowRationale({ permission: 'camera' });
|
|
181
|
+
* if (shouldShow) {
|
|
182
|
+
* await showWhyWeNeedCamera();
|
|
183
|
+
* await Permissions.request({ permission: 'camera' });
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
139
186
|
*/
|
|
140
187
|
shouldShowRationale(options: PermissionOptions): Promise<ShouldShowRationaleResult>;
|
|
141
188
|
/**
|
|
@@ -143,6 +190,11 @@ export interface PermissionsPlugin {
|
|
|
143
190
|
* Rejects on web with `UNIMPLEMENTED`.
|
|
144
191
|
*
|
|
145
192
|
* @param options.type Settings destination. Defaults to `application`.
|
|
193
|
+
* @since 8.0.0
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* await Permissions.openSettings({ type: 'notifications' });
|
|
197
|
+
* ```
|
|
146
198
|
*/
|
|
147
199
|
openSettings(options?: OpenSettingsOptions): Promise<void>;
|
|
148
200
|
/**
|
|
@@ -150,10 +202,18 @@ export interface PermissionsPlugin {
|
|
|
150
202
|
* On iOS, requests temporary full accuracy when already authorized when-in-use.
|
|
151
203
|
* On Android, requests `ACCESS_FINE_LOCATION`.
|
|
152
204
|
* On web, returns the geolocation permission status after prompting when possible.
|
|
205
|
+
*
|
|
206
|
+
* @since 8.0.0
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* const { status } = await Permissions.requestPreciseLocation();
|
|
210
|
+
* ```
|
|
153
211
|
*/
|
|
154
212
|
requestPreciseLocation(): Promise<PermissionStatusResult>;
|
|
155
213
|
/**
|
|
156
214
|
* Returns the platform implementation version marker.
|
|
215
|
+
*
|
|
216
|
+
* @since 8.0.0
|
|
157
217
|
*/
|
|
158
218
|
getPluginVersion(): Promise<PluginVersionResult>;
|
|
159
219
|
}
|
|
@@ -1 +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 *
|
|
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 *\n * @since 8.0.0\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 *\n * @since 8.0.0\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 * Logical permission to evaluate or request.\n *\n * @since 8.0.0\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 * @since 8.0.0\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. On `requestMultiple`, each permission is requested one after another.\n *\n * @since 8.0.0\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. Keys match the names passed in `permissions`.\n *\n * @since 8.0.0\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 * @since 8.0.0\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.\n *\n * @default 'application'\n * @since 8.0.0\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 * @since 8.0.0\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 * @since 8.0.0\n * @example\n * ```typescript\n * const { status } = await Permissions.check({ permission: 'camera' });\n * ```\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 * On iOS, triggers the platform authorization flow for the mapped capability.\n *\n * @param options.permission Logical permission to request.\n * @since 8.0.0\n * @example\n * ```typescript\n * const { status } = await Permissions.request({ permission: 'notifications' });\n * ```\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 * @since 8.0.0\n * @example\n * ```typescript\n * const { statuses } = await Permissions.checkMultiple({\n * permissions: ['camera', 'microphone'],\n * });\n * ```\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 * @since 8.0.0\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 * @since 8.0.0\n * @example\n * ```typescript\n * const { shouldShow } = await Permissions.shouldShowRationale({ permission: 'camera' });\n * if (shouldShow) {\n * await showWhyWeNeedCamera();\n * await Permissions.request({ permission: 'camera' });\n * }\n * ```\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 * @since 8.0.0\n * @example\n * ```typescript\n * await Permissions.openSettings({ type: 'notifications' });\n * ```\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 * @since 8.0.0\n * @example\n * ```typescript\n * const { status } = await Permissions.requestPreciseLocation();\n * ```\n */\n requestPreciseLocation(): Promise<PermissionStatusResult>;\n\n /**\n * Returns the platform implementation version marker.\n *\n * @since 8.0.0\n */\n getPluginVersion(): Promise<PluginVersionResult>;\n}\n"]}
|