@capgo/capacitor-permissions 0.0.0-stage → 8.2.2
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 +456 -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 +587 -0
- package/dist/esm/definitions.d.ts +219 -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/README.md
CHANGED
|
@@ -1,3 +1,457 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @capgo/capacitor-permissions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-permissions" alt="Capgo - Instant updates for Capacitor" /></a>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h2><a href="https://capgo.app/?ref=plugin_permissions"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
7
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin_permissions"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
**@capgo/capacitor-permissions** gives Capacitor apps one TypeScript API to check and request runtime permissions on iOS, Android, and web. Instead of wiring each feature plugin separately or guessing platform-specific status codes, you work with a single set of permission names and normalized states (`granted`, `denied`, `blocked`, `limited`, `unavailable`). Native manifests stay lean: the plugin ships without `uses-permission` entries or forced Info.plist strings, so store review only sees what your app declares.
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- One `PermissionName` enum for camera, location, notifications, media, contacts, and more across platforms
|
|
15
|
+
- `check`, `request`, `checkMultiple`, and `requestMultiple` with shared `AppPermissionState` results
|
|
16
|
+
- Android `shouldShowRationale` before re-prompting after a denial
|
|
17
|
+
- `openSettings` for application or notification settings when access is blocked
|
|
18
|
+
- `requestPreciseLocation` for full accuracy on iOS and `ACCESS_FINE_LOCATION` on Android
|
|
19
|
+
- Web implementation via the browser Permissions API for supported types
|
|
20
|
+
- Optional `scripts/apply-permissions.mjs` to add only the Android and iOS declarations you need
|
|
21
|
+
|
|
22
|
+
### Use cases
|
|
23
|
+
|
|
24
|
+
- Gate a screen until camera or microphone access is granted
|
|
25
|
+
- Run a startup audit with `checkMultiple` and show a single onboarding flow for missing permissions
|
|
26
|
+
- Send users to system settings when status is `blocked` after `openSettings`
|
|
27
|
+
- Request notification permission before registering push tokens
|
|
28
|
+
- Upgrade from reduced to precise location when a map feature needs it
|
|
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
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="./screenshots/android-request.webp" alt="Android emulator showing the camera permission dialog" width="280" />
|
|
38
|
+
<img src="./screenshots/android-granted.webp" alt="Example app reporting camera permission as granted" width="280" />
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
## Compatibility
|
|
42
|
+
|
|
43
|
+
| Plugin version | Capacitor compatibility | Maintained |
|
|
44
|
+
| -------------- | ----------------------- | ---------- |
|
|
45
|
+
| v8.\*.\* | v8.\*.\* | ✅ |
|
|
46
|
+
| v7.\*.\* | v7.\*.\* | On demand |
|
|
47
|
+
| v6.\*.\* | v6.\*.\* | On demand |
|
|
48
|
+
|
|
49
|
+
Policy:
|
|
50
|
+
|
|
51
|
+
- New plugins start at version `8.0.0` (Capacitor 8 baseline).
|
|
52
|
+
- Backward compatibility for older Capacitor majors is supported on demand.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install @capgo/capacitor-permissions
|
|
58
|
+
npx cap sync
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
With Bun:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun add @capgo/capacitor-permissions
|
|
65
|
+
bunx cap sync
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## iOS setup
|
|
69
|
+
|
|
70
|
+
The plugin does not inject usage descriptions into your app. For each `PermissionName` you call at runtime, add the matching keys to `ios/App/App/Info.plist` (customize the user-facing strings):
|
|
71
|
+
|
|
72
|
+
| Permission | Info.plist keys |
|
|
73
|
+
| ---------- | ---------------- |
|
|
74
|
+
| `camera` | `NSCameraUsageDescription` |
|
|
75
|
+
| `microphone` | `NSMicrophoneUsageDescription` |
|
|
76
|
+
| `photoLibrary` | `NSPhotoLibraryUsageDescription` |
|
|
77
|
+
| `photoLibraryAddOnly` | `NSPhotoLibraryAddUsageDescription` |
|
|
78
|
+
| `contacts` | `NSContactsUsageDescription` |
|
|
79
|
+
| `calendar` | `NSCalendarsUsageDescription`, `NSCalendarsFullAccessUsageDescription` |
|
|
80
|
+
| `reminders` | `NSRemindersUsageDescription`, `NSRemindersFullAccessUsageDescription` |
|
|
81
|
+
| `locationWhenInUse` | `NSLocationWhenInUseUsageDescription` |
|
|
82
|
+
| `locationAlways` | `NSLocationWhenInUseUsageDescription`, `NSLocationAlwaysAndWhenInUseUsageDescription` |
|
|
83
|
+
| `bluetooth` | `NSBluetoothAlwaysUsageDescription` |
|
|
84
|
+
| `motion` | `NSMotionUsageDescription` |
|
|
85
|
+
| `speechRecognition` | `NSSpeechRecognitionUsageDescription`, `NSMicrophoneUsageDescription` |
|
|
86
|
+
| `appTrackingTransparency` | `NSUserTrackingUsageDescription` |
|
|
87
|
+
|
|
88
|
+
`notifications` on iOS uses the system notification permission flow; no extra usage string is required for the API itself. Permissions such as `activityRecognition`, `phone`, `sms`, and Android-style media splits are not applicable on iOS and report `unavailable` when checked.
|
|
89
|
+
|
|
90
|
+
You can apply the keys above automatically from the plugin repo:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
node node_modules/@capgo/capacitor-permissions/scripts/apply-permissions.mjs \
|
|
94
|
+
--project . \
|
|
95
|
+
--permissions camera,microphone,notifications,locationWhenInUse,photoLibrary
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
(Point `--project` at your Capacitor app root, the folder that contains `ios/` and `android/`.)
|
|
99
|
+
|
|
100
|
+
## Android setup
|
|
101
|
+
|
|
102
|
+
The library `AndroidManifest.xml` declares **no** `<uses-permission>` entries. Add only what your app uses to `android/app/src/main/AndroidManifest.xml`. The plugin targets **minSdk 24** (Android 7.0) unless your project overrides `minSdkVersion`.
|
|
103
|
+
|
|
104
|
+
| Permission | Typical `uses-permission` names |
|
|
105
|
+
| ---------- | -------------------------------- |
|
|
106
|
+
| `camera` | `android.permission.CAMERA` |
|
|
107
|
+
| `microphone`, `speechRecognition` | `android.permission.RECORD_AUDIO` |
|
|
108
|
+
| `photoLibrary`, `mediaImages` | `READ_MEDIA_IMAGES`, `READ_MEDIA_VISUAL_USER_SELECTED`, `READ_EXTERNAL_STORAGE` (legacy) |
|
|
109
|
+
| `photoLibraryAddOnly` | `WRITE_EXTERNAL_STORAGE` (legacy) |
|
|
110
|
+
| `contacts` | `READ_CONTACTS` |
|
|
111
|
+
| `calendar` | `READ_CALENDAR`, `WRITE_CALENDAR` |
|
|
112
|
+
| `locationWhenInUse` | `ACCESS_COARSE_LOCATION`, `ACCESS_FINE_LOCATION` |
|
|
113
|
+
| `locationAlways` | above plus `ACCESS_BACKGROUND_LOCATION` |
|
|
114
|
+
| `bluetooth` | `BLUETOOTH`, `BLUETOOTH_ADMIN`, `BLUETOOTH_CONNECT`, `BLUETOOTH_SCAN` |
|
|
115
|
+
| `motion`, `activityRecognition` | `ACTIVITY_RECOGNITION` |
|
|
116
|
+
| `notifications` | `POST_NOTIFICATIONS` (Android 13+) |
|
|
117
|
+
| `phone` | `READ_PHONE_STATE` |
|
|
118
|
+
| `sms` | `READ_SMS`, `RECEIVE_SMS` |
|
|
119
|
+
| `mediaAudio` | `READ_MEDIA_AUDIO`, `READ_EXTERNAL_STORAGE` |
|
|
120
|
+
| `mediaVideo` | `READ_MEDIA_VIDEO`, `READ_EXTERNAL_STORAGE` |
|
|
121
|
+
|
|
122
|
+
`reminders` and `appTrackingTransparency` are not Android runtime permissions in this API and return `unavailable`.
|
|
123
|
+
|
|
124
|
+
Use the same `apply-permissions.mjs` script as on iOS to merge declarations into your app manifest.
|
|
125
|
+
|
|
126
|
+
## Web setup
|
|
127
|
+
|
|
128
|
+
No manifest changes. Supported permissions use `navigator.permissions` and related APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`; `locationAlways` maps to foreground geolocation only). Others return `unavailable`. `openSettings` is not implemented on web.
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { Permissions } from '@capgo/capacitor-permissions';
|
|
134
|
+
|
|
135
|
+
export async function ensureCamera(): Promise<boolean> {
|
|
136
|
+
const { status } = await Permissions.check({ permission: 'camera' });
|
|
137
|
+
if (status === 'granted') {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
const { status: afterRequest } = await Permissions.request({ permission: 'camera' });
|
|
141
|
+
return afterRequest === 'granted';
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Check several permissions before showing an onboarding screen:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const { statuses } = await Permissions.checkMultiple({
|
|
149
|
+
permissions: ['camera', 'microphone', 'notifications'],
|
|
150
|
+
});
|
|
151
|
+
const missing = Object.entries(statuses).filter(([, s]) => s !== 'granted');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
When Android reports `denied`, show context before requesting again:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
const { shouldShow } = await Permissions.shouldShowRationale({ permission: 'camera' });
|
|
158
|
+
if (shouldShow) {
|
|
159
|
+
// Show your own explanation UI, then:
|
|
160
|
+
await Permissions.request({ permission: 'camera' });
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If status is `blocked`, send the user to settings:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
await Permissions.openSettings({ type: 'application' });
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Example app
|
|
171
|
+
|
|
172
|
+
The `example-app/` project exercises every `PermissionName`. Apply declarations, sync native projects, then:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
cd example-app
|
|
176
|
+
bun install
|
|
177
|
+
bun run start
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## API
|
|
181
|
+
|
|
182
|
+
<docgen-index>
|
|
183
|
+
|
|
184
|
+
* [`check(...)`](#check)
|
|
185
|
+
* [`request(...)`](#request)
|
|
186
|
+
* [`checkMultiple(...)`](#checkmultiple)
|
|
187
|
+
* [`requestMultiple(...)`](#requestmultiple)
|
|
188
|
+
* [`shouldShowRationale(...)`](#shouldshowrationale)
|
|
189
|
+
* [`openSettings(...)`](#opensettings)
|
|
190
|
+
* [`requestPreciseLocation()`](#requestpreciselocation)
|
|
191
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
192
|
+
* [Interfaces](#interfaces)
|
|
193
|
+
* [Type Aliases](#type-aliases)
|
|
194
|
+
|
|
195
|
+
</docgen-index>
|
|
196
|
+
|
|
197
|
+
<docgen-api>
|
|
198
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
199
|
+
|
|
200
|
+
Cross-platform permissions API for Capacitor apps.
|
|
201
|
+
|
|
202
|
+
### check(...)
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
check(options: PermissionOptions) => Promise<PermissionStatusResult>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Check the current status of one permission without prompting the user.
|
|
209
|
+
|
|
210
|
+
| Param | Type |
|
|
211
|
+
| ------------- | --------------------------------------------------------------- |
|
|
212
|
+
| **`options`** | <code><a href="#permissionoptions">PermissionOptions</a></code> |
|
|
213
|
+
|
|
214
|
+
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
215
|
+
|
|
216
|
+
**Since:** 8.0.0
|
|
217
|
+
|
|
218
|
+
--------------------
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
### request(...)
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
request(options: PermissionOptions) => Promise<PermissionStatusResult>
|
|
225
|
+
```
|
|
226
|
+
|
|
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.
|
|
229
|
+
|
|
230
|
+
| Param | Type |
|
|
231
|
+
| ------------- | --------------------------------------------------------------- |
|
|
232
|
+
| **`options`** | <code><a href="#permissionoptions">PermissionOptions</a></code> |
|
|
233
|
+
|
|
234
|
+
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
235
|
+
|
|
236
|
+
**Since:** 8.0.0
|
|
237
|
+
|
|
238
|
+
--------------------
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### checkMultiple(...)
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
checkMultiple(options: MultiplePermissionOptions) => Promise<MultiplePermissionStatusResult>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Check several permissions without prompting.
|
|
248
|
+
|
|
249
|
+
| Param | Type |
|
|
250
|
+
| ------------- | ------------------------------------------------------------------------------- |
|
|
251
|
+
| **`options`** | <code><a href="#multiplepermissionoptions">MultiplePermissionOptions</a></code> |
|
|
252
|
+
|
|
253
|
+
**Returns:** <code>Promise<<a href="#multiplepermissionstatusresult">MultiplePermissionStatusResult</a>></code>
|
|
254
|
+
|
|
255
|
+
**Since:** 8.0.0
|
|
256
|
+
|
|
257
|
+
--------------------
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
### requestMultiple(...)
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
requestMultiple(options: MultiplePermissionOptions) => Promise<MultiplePermissionStatusResult>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Request several permissions sequentially so dialogs are not shown on top of each other.
|
|
267
|
+
|
|
268
|
+
| Param | Type |
|
|
269
|
+
| ------------- | ------------------------------------------------------------------------------- |
|
|
270
|
+
| **`options`** | <code><a href="#multiplepermissionoptions">MultiplePermissionOptions</a></code> |
|
|
271
|
+
|
|
272
|
+
**Returns:** <code>Promise<<a href="#multiplepermissionstatusresult">MultiplePermissionStatusResult</a>></code>
|
|
273
|
+
|
|
274
|
+
**Since:** 8.0.0
|
|
275
|
+
|
|
276
|
+
--------------------
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
### shouldShowRationale(...)
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
shouldShowRationale(options: PermissionOptions) => Promise<ShouldShowRationaleResult>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Whether Android should show a rationale before requesting again.
|
|
286
|
+
Returns `{ shouldShow: false }` on iOS and web.
|
|
287
|
+
|
|
288
|
+
| Param | Type |
|
|
289
|
+
| ------------- | --------------------------------------------------------------- |
|
|
290
|
+
| **`options`** | <code><a href="#permissionoptions">PermissionOptions</a></code> |
|
|
291
|
+
|
|
292
|
+
**Returns:** <code>Promise<<a href="#shouldshowrationaleresult">ShouldShowRationaleResult</a>></code>
|
|
293
|
+
|
|
294
|
+
**Since:** 8.0.0
|
|
295
|
+
|
|
296
|
+
--------------------
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
### openSettings(...)
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
openSettings(options?: OpenSettingsOptions | undefined) => Promise<void>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Open the application or notification settings screen.
|
|
306
|
+
Rejects on web with `UNIMPLEMENTED`.
|
|
307
|
+
|
|
308
|
+
| Param | Type |
|
|
309
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
310
|
+
| **`options`** | <code><a href="#opensettingsoptions">OpenSettingsOptions</a></code> |
|
|
311
|
+
|
|
312
|
+
**Since:** 8.0.0
|
|
313
|
+
|
|
314
|
+
--------------------
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
### requestPreciseLocation()
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
requestPreciseLocation() => Promise<PermissionStatusResult>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Ask for precise location.
|
|
324
|
+
On iOS, requests temporary full accuracy when already authorized when-in-use.
|
|
325
|
+
On Android, requests `ACCESS_FINE_LOCATION`.
|
|
326
|
+
On web, returns the geolocation permission status after prompting when possible.
|
|
327
|
+
|
|
328
|
+
**Returns:** <code>Promise<<a href="#permissionstatusresult">PermissionStatusResult</a>></code>
|
|
329
|
+
|
|
330
|
+
**Since:** 8.0.0
|
|
331
|
+
|
|
332
|
+
--------------------
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
### getPluginVersion()
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
getPluginVersion() => Promise<PluginVersionResult>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Returns the platform implementation version marker.
|
|
342
|
+
|
|
343
|
+
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
344
|
+
|
|
345
|
+
**Since:** 8.0.0
|
|
346
|
+
|
|
347
|
+
--------------------
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
### Interfaces
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
#### PermissionStatusResult
|
|
354
|
+
|
|
355
|
+
Result for a single permission status.
|
|
356
|
+
|
|
357
|
+
| Prop | Type | Description | Since |
|
|
358
|
+
| ------------ | ----------------------------------------------------------------- | -------------------------------------------- | ----- |
|
|
359
|
+
| **`status`** | <code><a href="#apppermissionstate">AppPermissionState</a></code> | Current status for the requested permission. | 8.0.0 |
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
#### PermissionOptions
|
|
363
|
+
|
|
364
|
+
Options for checking or requesting a single permission.
|
|
365
|
+
|
|
366
|
+
| Prop | Type | Description | Since |
|
|
367
|
+
| ---------------- | --------------------------------------------------------- | ------------------------------------------ | ----- |
|
|
368
|
+
| **`permission`** | <code><a href="#permissionname">PermissionName</a></code> | Logical permission to evaluate or request. | 8.0.0 |
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
#### MultiplePermissionStatusResult
|
|
372
|
+
|
|
373
|
+
Result for several permission statuses.
|
|
374
|
+
|
|
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 |
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
#### MultiplePermissionOptions
|
|
381
|
+
|
|
382
|
+
Options for checking or requesting several permissions.
|
|
383
|
+
|
|
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 |
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
#### ShouldShowRationaleResult
|
|
390
|
+
|
|
391
|
+
Result for Android rationale checks.
|
|
392
|
+
|
|
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 |
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
#### OpenSettingsOptions
|
|
399
|
+
|
|
400
|
+
Options for opening system settings.
|
|
401
|
+
|
|
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 |
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
#### PluginVersionResult
|
|
408
|
+
|
|
409
|
+
Plugin version payload.
|
|
410
|
+
|
|
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 |
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
### Type Aliases
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
#### AppPermissionState
|
|
420
|
+
|
|
421
|
+
Normalized permission status returned by every platform implementation.
|
|
422
|
+
|
|
423
|
+
- `granted`: the user allowed full access.
|
|
424
|
+
- `denied`: the user has not granted access yet, or Android can show a rationale.
|
|
425
|
+
- `blocked`: the user denied access and the app cannot prompt again without settings.
|
|
426
|
+
- `limited`: partial access (for example iOS limited photo library or reduced location accuracy).
|
|
427
|
+
- `unavailable`: the permission is not supported on this platform or not declared in the app manifest.
|
|
428
|
+
|
|
429
|
+
<code>'granted' | 'denied' | 'blocked' | 'limited' | 'unavailable'</code>
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
#### PermissionName
|
|
433
|
+
|
|
434
|
+
Logical permission identifiers shared across iOS, Android, and web.
|
|
435
|
+
|
|
436
|
+
Android-only names include `activityRecognition`, `phone`, `sms`, `mediaAudio`, `mediaImages`, and `mediaVideo`.
|
|
437
|
+
iOS-only names include `reminders` and `appTrackingTransparency`.
|
|
438
|
+
Web supports a subset via browser APIs (`camera`, `microphone`, `notifications`, `locationWhenInUse`).
|
|
439
|
+
On web, `locationAlways` is an alias of foreground geolocation only; browsers do not expose background location permission.
|
|
440
|
+
|
|
441
|
+
<code>'camera' | 'microphone' | 'photoLibrary' | 'photoLibraryAddOnly' | 'contacts' | 'calendar' | 'reminders' | 'locationWhenInUse' | 'locationAlways' | 'bluetooth' | 'motion' | 'notifications' | 'speechRecognition' | 'appTrackingTransparency' | 'activityRecognition' | 'phone' | 'sms' | 'mediaAudio' | 'mediaImages' | 'mediaVideo'</code>
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
#### Record
|
|
445
|
+
|
|
446
|
+
Construct a type with a set of properties K of type T
|
|
447
|
+
|
|
448
|
+
<code>{
|
|
4
449
|
[P in K]: T;
|
|
5
450
|
}</code>
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
#### SettingsType
|
|
454
|
+
|
|
455
|
+
Settings screen type for `openSettings`.
|
|
456
|
+
|
|
457
|
+
<code>'application' | 'notifications'</code>
|
|
458
|
+
|
|
459
|
+
</docgen-api>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.17.0'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
buildscript {
|
|
10
|
+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
|
|
11
|
+
repositories {
|
|
12
|
+
google()
|
|
13
|
+
mavenCentral()
|
|
14
|
+
}
|
|
15
|
+
dependencies {
|
|
16
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
17
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: 'com.android.library'
|
|
22
|
+
apply plugin: 'kotlin-android'
|
|
23
|
+
|
|
24
|
+
android {
|
|
25
|
+
namespace = "app.capgo.permissions"
|
|
26
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
29
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
30
|
+
versionCode 1
|
|
31
|
+
versionName "1.0"
|
|
32
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
33
|
+
}
|
|
34
|
+
buildTypes {
|
|
35
|
+
release {
|
|
36
|
+
minifyEnabled false
|
|
37
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
lint {
|
|
41
|
+
abortOnError = false
|
|
42
|
+
}
|
|
43
|
+
compileOptions {
|
|
44
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
45
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
kotlin {
|
|
50
|
+
jvmToolchain(21)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
repositories {
|
|
54
|
+
google()
|
|
55
|
+
mavenCentral()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
dependencies {
|
|
59
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
60
|
+
implementation project(':capacitor-android')
|
|
61
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
62
|
+
implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"
|
|
63
|
+
testImplementation "junit:junit:$junitVersion"
|
|
64
|
+
testImplementation 'org.robolectric:robolectric:4.14.1'
|
|
65
|
+
testImplementation 'androidx.test:core:1.7.0'
|
|
66
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
67
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
68
|
+
}
|