@cap-kit/settings 8.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CapKitSettings.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +29 -0
  4. package/README.md +428 -0
  5. package/android/build.gradle +103 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capkit/settings/SettingsConfig.kt +39 -0
  8. package/android/src/main/java/io/capkit/settings/SettingsImpl.kt +95 -0
  9. package/android/src/main/java/io/capkit/settings/SettingsPlugin.kt +91 -0
  10. package/android/src/main/java/io/capkit/settings/utils/SettingsLogger.kt +85 -0
  11. package/android/src/main/java/io/capkit/settings/utils/SettingsUtils.kt +75 -0
  12. package/android/src/main/res/.gitkeep +0 -0
  13. package/dist/docs.json +877 -0
  14. package/dist/esm/definitions.d.ts +686 -0
  15. package/dist/esm/definitions.js +423 -0
  16. package/dist/esm/definitions.js.map +1 -0
  17. package/dist/esm/index.d.ts +16 -0
  18. package/dist/esm/index.js +19 -0
  19. package/dist/esm/index.js.map +1 -0
  20. package/dist/esm/web.d.ts +43 -0
  21. package/dist/esm/web.js +68 -0
  22. package/dist/esm/web.js.map +1 -0
  23. package/dist/plugin.cjs.js +516 -0
  24. package/dist/plugin.cjs.js.map +1 -0
  25. package/dist/plugin.js +519 -0
  26. package/dist/plugin.js.map +1 -0
  27. package/ios/Sources/SettingsPlugin/SettingsConfig.swift +54 -0
  28. package/ios/Sources/SettingsPlugin/SettingsImpl.swift +84 -0
  29. package/ios/Sources/SettingsPlugin/SettingsPlugin.swift +103 -0
  30. package/ios/Sources/SettingsPlugin/Utils/SettingsLogger.swift +57 -0
  31. package/ios/Sources/SettingsPlugin/Utils/SettingsUtils.swift +70 -0
  32. package/ios/Sources/SettingsPlugin/Version.swift +16 -0
  33. package/ios/Tests/SettingsPluginTests/SettingsPluginTests.swift +21 -0
  34. package/package.json +98 -0
@@ -0,0 +1,686 @@
1
+ /**
2
+ * Capacitor configuration extension for the Settings plugin.
3
+ *
4
+ * Configuration values defined here can be provided under the `plugins.Settings`
5
+ * key inside `capacitor.config.ts`.
6
+ *
7
+ * These values are:
8
+ * - read natively at build/runtime
9
+ * - NOT accessible from JavaScript at runtime
10
+ * - treated as read-only static configuration
11
+ */
12
+ declare module '@capacitor/cli' {
13
+ interface PluginsConfig {
14
+ /**
15
+ * Configuration options for the Settings plugin.
16
+ */
17
+ Settings?: SettingsConfig;
18
+ }
19
+ }
20
+ /**
21
+ * Static configuration options for the Settings plugin.
22
+ *
23
+ * These values are defined in `capacitor.config.ts` and consumed
24
+ * exclusively by native code during plugin initialization.
25
+ *
26
+ * Configuration values:
27
+ * - do NOT change the JavaScript API shape
28
+ * - do NOT enable/disable methods
29
+ * - are applied once during plugin load
30
+ */
31
+ export interface SettingsConfig {
32
+ /**
33
+ * Enables verbose native logging.
34
+ *
35
+ * When enabled, additional debug information is printed
36
+ * to the native console (Logcat on Android, Xcode on iOS).
37
+ *
38
+ * This option affects native logging behavior only and
39
+ * has no impact on the JavaScript API.
40
+ *
41
+ * @default false
42
+ * @example true
43
+ * @since 1.0.0
44
+ */
45
+ verboseLogging?: boolean;
46
+ }
47
+ /**
48
+ * Standardized error codes used by the Settings plugin.
49
+ *
50
+ * These codes are returned as part of structured error objects
51
+ * and allow consumers to implement programmatic error handling.
52
+ *
53
+ * Note:
54
+ * On iOS (Swift Package Manager), errors are returned as data
55
+ * objects rather than rejected Promises.
56
+ *
57
+ * @since 1.0.0
58
+ */
59
+ export declare enum SettingsErrorCode {
60
+ /** The device does not have the requested hardware. */
61
+ UNAVAILABLE = "UNAVAILABLE",
62
+ /** The user denied the permission or the feature is disabled in settings. */
63
+ PERMISSION_DENIED = "PERMISSION_DENIED",
64
+ /** The Settings plugin failed to initialize (e.g., runtime error or Looper failure). */
65
+ INIT_FAILED = "INIT_FAILED",
66
+ /** The requested Settings plugin type is not valid or not supported by the plugin. */
67
+ UNKNOWN_TYPE = "UNKNOWN_TYPE"
68
+ }
69
+ /**
70
+ * Result object returned by the `getPluginVersion()` method.
71
+ */
72
+ export interface PluginVersionResult {
73
+ /**
74
+ * The native plugin version string.
75
+ */
76
+ version: string;
77
+ }
78
+ /**
79
+ * Structured error object returned by Settings plugin operations.
80
+ *
81
+ * This object allows consumers to handle errors without relying
82
+ * on exception-based control flow.
83
+ */
84
+ export interface SettingsError {
85
+ /**
86
+ * Human-readable error description.
87
+ */
88
+ message: string;
89
+ /**
90
+ * Machine-readable error code.
91
+ */
92
+ code: SettingsErrorCode;
93
+ }
94
+ /**
95
+ * Response object for settings open operations.
96
+ *
97
+ * All platforms return a state-based result object.
98
+ * Promise rejection is NOT used.
99
+ */
100
+ export interface SettingsResult {
101
+ /**
102
+ * Indicates if the operation was successful.
103
+ */
104
+ success: boolean;
105
+ /**
106
+ * Human-readable error message, if the operation failed.
107
+ */
108
+ error?: string;
109
+ /**
110
+ * Machine-readable error code.
111
+ *
112
+ * This field is present when `success` is false and allows
113
+ * programmatic handling of platform limitations or failures.
114
+ *
115
+ * @example SettingsErrorCode.UNAVAILABLE
116
+ */
117
+ code?: SettingsErrorCode;
118
+ }
119
+ /**
120
+ * Platform-specific options for opening system settings.
121
+ *
122
+ * This interface allows specifying settings options for both
123
+ * Android and iOS in a single call.
124
+ *
125
+ * @remarks
126
+ * The plugin will use the option corresponding to the
127
+ * current runtime platform.
128
+ *
129
+ * Unsupported or unavailable options on the current platform
130
+ * will result in a resolved response with:
131
+ * `{ success: false, code: SettingsErrorCode.UNAVAILABLE }`
132
+ *
133
+ * Availability and behavior depend on platform-specific
134
+ * system capabilities and restrictions.
135
+ */
136
+ export interface PlatformOptions {
137
+ /**
138
+ * Android settings option to open.
139
+ *
140
+ * Used only when running on Android.
141
+ * Mapped internally to a system Intent.
142
+ */
143
+ optionAndroid: AndroidSettings;
144
+ /**
145
+ * iOS settings option to open.
146
+ *
147
+ * Used only when running on iOS.
148
+ * Mapped internally to an iOS settings URL scheme.
149
+ */
150
+ optionIOS: IOSSettings;
151
+ }
152
+ /**
153
+ * Android-specific options for opening system settings.
154
+ *
155
+ * @platform Android
156
+ *
157
+ * @remarks
158
+ * Android settings are opened via system Intents.
159
+ * Availability and behavior depend on:
160
+ *
161
+ * - Android version
162
+ * - device manufacturer (OEM)
163
+ * - system configuration and user restrictions
164
+ *
165
+ * Some settings rely on intents that are not part of the public
166
+ * Android SDK and may not be available on all devices.
167
+ *
168
+ * When a requested settings screen cannot be resolved, the plugin
169
+ * resolves with:
170
+ * `{ success: false, code: SettingsErrorCode.UNAVAILABLE }`
171
+ *
172
+ * This interface does NOT guarantee that a given settings screen
173
+ * will open successfully on all devices.
174
+ */
175
+ export interface AndroidOptions {
176
+ /**
177
+ * The Android settings section to open.
178
+ *
179
+ * Each value maps to a specific Android system Intent.
180
+ * Support varies depending on the device and OS version.
181
+ *
182
+ * @example AndroidSettings.Wifi
183
+ * @example AndroidSettings.Bluetooth
184
+ * @example AndroidSettings.ApplicationDetails
185
+ */
186
+ option: AndroidSettings;
187
+ }
188
+ /**
189
+ * iOS-specific options for opening system settings.
190
+ *
191
+ * @platform iOS
192
+ *
193
+ * @remarks
194
+ * Apple officially supports opening only the app-specific settings screen.
195
+ * All other settings destinations rely on undocumented URL schemes and may:
196
+ *
197
+ * - behave differently across iOS versions
198
+ * - stop working in future iOS releases
199
+ * - be restricted or rejected during App Store review
200
+ *
201
+ * For unsupported or unavailable settings, the plugin resolves with:
202
+ * `{ success: false, code: SettingsErrorCode.UNAVAILABLE }`
203
+ *
204
+ * This interface does NOT guarantee that a given settings screen
205
+ * will open successfully on all devices.
206
+ */
207
+ export interface IOSOptions {
208
+ /**
209
+ * The iOS settings section to open.
210
+ *
211
+ * Most values correspond to internal iOS URL schemes.
212
+ * Availability depends on the iOS version and system configuration.
213
+ *
214
+ * @example IOSSettings.App
215
+ * @example IOSSettings.AppNotification
216
+ * @example IOSSettings.Bluetooth
217
+ */
218
+ option: IOSSettings;
219
+ }
220
+ /**
221
+ * Enumeration of supported Android system settings.
222
+ *
223
+ * @platform Android
224
+ *
225
+ * @remarks
226
+ * Android settings are opened via system Intents.
227
+ * Availability depends on:
228
+ *
229
+ * - Android version
230
+ * - device manufacturer (OEM)
231
+ * - system configuration and user restrictions
232
+ *
233
+ * Some intents are not part of the public Android SDK and may not be
234
+ * available on all devices.
235
+ *
236
+ * When a requested settings screen cannot be resolved, the plugin
237
+ * resolves with:
238
+ * `{ success: false, code: SettingsErrorCode.UNAVAILABLE }`
239
+ *
240
+ * @since 1.0.0
241
+ */
242
+ export declare enum AndroidSettings {
243
+ /**
244
+ * Opens Accessibility settings.
245
+ */
246
+ Accessibility = "accessibility",
247
+ /**
248
+ * Opens the Add Account screen.
249
+ */
250
+ Account = "account",
251
+ /**
252
+ * Opens Airplane Mode settings.
253
+ */
254
+ AirplaneMode = "airplane_mode",
255
+ /**
256
+ * Opens Access Point Name (APN) settings.
257
+ */
258
+ Apn = "apn",
259
+ /**
260
+ * Opens the Application Details screen for the current app.
261
+ */
262
+ ApplicationDetails = "application_details",
263
+ /**
264
+ * Opens Application Development settings.
265
+ *
266
+ * Availability depends on developer options being enabled.
267
+ */
268
+ ApplicationDevelopment = "application_development",
269
+ /**
270
+ * Opens Application settings.
271
+ */
272
+ Application = "application",
273
+ /**
274
+ * Opens app-specific notification settings.
275
+ */
276
+ AppNotification = "app_notification",
277
+ /**
278
+ * Opens Battery Optimization settings.
279
+ *
280
+ * Allows managing apps excluded from battery optimizations.
281
+ */
282
+ BatteryOptimization = "battery_optimization",
283
+ /**
284
+ * Opens Bluetooth settings.
285
+ */
286
+ Bluetooth = "bluetooth",
287
+ /**
288
+ * Opens Captioning settings.
289
+ */
290
+ Captioning = "captioning",
291
+ /**
292
+ * Opens Cast device settings.
293
+ */
294
+ Cast = "cast",
295
+ /**
296
+ * Opens Data Roaming settings.
297
+ */
298
+ DataRoaming = "data_roaming",
299
+ /**
300
+ * Opens Date & Time settings.
301
+ */
302
+ Date = "date",
303
+ /**
304
+ * Opens Display settings.
305
+ */
306
+ Display = "display",
307
+ /**
308
+ * Opens Dream (Daydream / Screensaver) settings.
309
+ */
310
+ Dream = "dream",
311
+ /**
312
+ * Opens Home app selection settings.
313
+ */
314
+ Home = "home",
315
+ /**
316
+ * Opens Input Method (Keyboard) settings.
317
+ */
318
+ Keyboard = "keyboard",
319
+ /**
320
+ * Opens Input Method Subtype settings.
321
+ */
322
+ KeyboardSubType = "keyboard_subtype",
323
+ /**
324
+ * Opens Language & Input (Locale) settings.
325
+ */
326
+ Locale = "locale",
327
+ /**
328
+ * Opens Location Services settings.
329
+ */
330
+ Location = "location",
331
+ /**
332
+ * Opens Manage Applications settings.
333
+ */
334
+ ManageApplications = "manage_applications",
335
+ /**
336
+ * Opens Manage All Applications settings.
337
+ *
338
+ * Availability depends on Android version and OEM.
339
+ */
340
+ ManageAllApplications = "manage_all_applications",
341
+ /**
342
+ * Show settings for memory card storage
343
+ */
344
+ MemoryCard = "memory_card",
345
+ /**
346
+ * Opens Network Operator settings.
347
+ */
348
+ Network = "network",
349
+ /**
350
+ * Opens NFC settings.
351
+ */
352
+ Nfc = "nfc",
353
+ /**
354
+ * Opens NFC Sharing settings.
355
+ */
356
+ NfcSharing = "nfcsharing",
357
+ /**
358
+ * Opens NFC Payment settings.
359
+ */
360
+ NfcPayment = "nfc_payment",
361
+ /**
362
+ * Opens Print settings.
363
+ */
364
+ Print = "print",
365
+ /**
366
+ * Opens Privacy settings.
367
+ */
368
+ Privacy = "privacy",
369
+ /**
370
+ * Opens Quick Launch settings.
371
+ */
372
+ QuickLaunch = "quick_launch",
373
+ /**
374
+ * Opens Search settings.
375
+ */
376
+ Search = "search",
377
+ /**
378
+ * Opens Security settings.
379
+ */
380
+ Security = "security",
381
+ /**
382
+ * Opens the main System Settings screen.
383
+ */
384
+ Settings = "settings",
385
+ /**
386
+ * Opens Regulatory Information screen.
387
+ */
388
+ ShowRegulatoryInfo = "show_regulatory_info",
389
+ /**
390
+ * Opens Sound & Volume settings.
391
+ */
392
+ Sound = "sound",
393
+ /**
394
+ * Opens Internal Storage settings.
395
+ */
396
+ Storage = "storage",
397
+ /**
398
+ * Opens Sync settings.
399
+ */
400
+ Sync = "sync",
401
+ /**
402
+ * Opens Text-to-Speech (TTS) settings.
403
+ *
404
+ * Uses a non-public intent on some devices.
405
+ */
406
+ TextToSpeech = "text_to_speech",
407
+ /**
408
+ * Opens Usage Access settings.
409
+ *
410
+ * Allows managing apps with access to usage data.
411
+ */
412
+ Usage = "usage",
413
+ /**
414
+ * Opens User Dictionary settings.
415
+ */
416
+ UserDictionary = "user_dictionary",
417
+ /**
418
+ * Opens Voice Input settings.
419
+ */
420
+ VoiceInput = "voice_input",
421
+ /**
422
+ * Opens VPN settings.
423
+ */
424
+ VPN = "vpn",
425
+ /**
426
+ * Opens Wi-Fi settings.
427
+ */
428
+ Wifi = "wifi",
429
+ /**
430
+ * Opens Wi-Fi IP settings.
431
+ *
432
+ * Availability varies by device and Android version.
433
+ */
434
+ WifiIp = "wifi_ip",
435
+ /**
436
+ * Opens Wireless & Networks settings.
437
+ */
438
+ Wireless = "wireless",
439
+ /**
440
+ * Opens Zen Mode (Do Not Disturb) settings.
441
+ *
442
+ * This uses a non-public intent and may not work on all devices.
443
+ */
444
+ ZenMode = "zen_mode",
445
+ /**
446
+ * Opens Zen Mode Priority settings.
447
+ */
448
+ ZenModePriority = "zen_mode_priority",
449
+ /**
450
+ * Opens Zen Mode Blocked Effects settings.
451
+ */
452
+ ZenModeBlockedEffects = "zen_mode_blocked_effects"
453
+ }
454
+ /**
455
+ * Enumeration of supported iOS system settings.
456
+ *
457
+ * @platform iOS
458
+ *
459
+ * @remarks
460
+ * Apple officially supports opening only the app-specific settings screen.
461
+ * All other values rely on undocumented URL schemes and may:
462
+ *
463
+ * - behave differently across iOS versions
464
+ * - stop working in future releases
465
+ * - be restricted during App Store review
466
+ *
467
+ * Availability is best-effort and not guaranteed.
468
+ *
469
+ * @since 1.0.0
470
+ */
471
+ export declare enum IOSSettings {
472
+ /**
473
+ * Opens the app-specific settings screen.
474
+ *
475
+ * This is the ONLY settings destination officially supported by Apple
476
+ * and is considered App Store safe.
477
+ */
478
+ App = "app",
479
+ /**
480
+ * Opens the app-specific notification settings.
481
+ *
482
+ * - iOS 16+: opens the dedicated notification settings screen
483
+ * - iOS <16: falls back to the app settings screen
484
+ */
485
+ AppNotification = "appNotification",
486
+ /**
487
+ * Opens iOS "About" settings.
488
+ */
489
+ About = "about",
490
+ /**
491
+ * Opens Auto-Lock settings.
492
+ */
493
+ AutoLock = "autoLock",
494
+ /**
495
+ * Opens Bluetooth settings.
496
+ */
497
+ Bluetooth = "bluetooth",
498
+ /**
499
+ * Opens Date & Time settings.
500
+ */
501
+ DateTime = "dateTime",
502
+ /**
503
+ * Opens FaceTime settings.
504
+ */
505
+ FaceTime = "facetime",
506
+ /**
507
+ * Opens General settings.
508
+ */
509
+ General = "general",
510
+ /**
511
+ * Opens Keyboard settings.
512
+ */
513
+ Keyboard = "keyboard",
514
+ /**
515
+ * Opens iCloud settings.
516
+ */
517
+ ICloud = "iCloud",
518
+ /**
519
+ * Opens iCloud Storage & Backup settings.
520
+ */
521
+ ICloudStorageBackup = "iCloudStorageBackup",
522
+ /**
523
+ * Opens Language & Region (International) settings.
524
+ */
525
+ International = "international",
526
+ /**
527
+ * Opens Location Services settings.
528
+ */
529
+ LocationServices = "locationServices",
530
+ /**
531
+ * Opens Music settings.
532
+ */
533
+ Music = "music",
534
+ /**
535
+ * Opens Notes settings.
536
+ */
537
+ Notes = "notes",
538
+ /**
539
+ * Opens Notifications settings.
540
+ *
541
+ * Note: this is the global notifications screen,
542
+ * not app-specific notifications.
543
+ */
544
+ Notifications = "notifications",
545
+ /**
546
+ * Opens Phone settings.
547
+ */
548
+ Phone = "phone",
549
+ /**
550
+ * Opens Photos settings.
551
+ */
552
+ Photos = "photos",
553
+ /**
554
+ * Opens Managed Configuration profiles list.
555
+ */
556
+ ManagedConfigurationList = "managedConfigurationList",
557
+ /**
558
+ * Opens Reset settings.
559
+ */
560
+ Reset = "reset",
561
+ /**
562
+ * Opens Ringtone settings.
563
+ */
564
+ Ringtone = "ringtone",
565
+ /**
566
+ * Opens Sounds settings.
567
+ */
568
+ Sounds = "sounds",
569
+ /**
570
+ * Opens Software Update settings.
571
+ */
572
+ SoftwareUpdate = "softwareUpdate",
573
+ /**
574
+ * Opens App Store settings.
575
+ */
576
+ Store = "store",
577
+ /**
578
+ * Opens App Tracking Transparency settings.
579
+ *
580
+ * Available on iOS 14+.
581
+ */
582
+ Tracking = "tracking",
583
+ /**
584
+ * Opens Wallpaper settings.
585
+ */
586
+ Wallpaper = "wallpaper",
587
+ /**
588
+ * Opens Wi-Fi settings.
589
+ */
590
+ WiFi = "wifi",
591
+ /**
592
+ * Opens Personal Hotspot (Tethering) settings.
593
+ */
594
+ Tethering = "tethering",
595
+ /**
596
+ * Opens Do Not Disturb settings.
597
+ */
598
+ DoNotDisturb = "doNotDisturb",
599
+ /**
600
+ * Opens Touch ID / Passcode settings.
601
+ */
602
+ TouchIdPasscode = "touchIdPasscode",
603
+ /**
604
+ * Opens Screen Time settings.
605
+ */
606
+ ScreenTime = "screenTime",
607
+ /**
608
+ * Opens Accessibility settings.
609
+ */
610
+ Accessibility = "accessibility",
611
+ /**
612
+ * Opens VPN settings.
613
+ */
614
+ VPN = "vpn"
615
+ }
616
+ /**
617
+ * Public JavaScript API for the Settings Capacitor plugin.
618
+ *
619
+ * This plugin uses a state-based result model:
620
+ * - operations never throw
621
+ * - Promise rejection is not used
622
+ * - failures are reported via `{ success, error?, code? }`
623
+ *
624
+ * This design ensures consistent behavior across Android, iOS, and Web.
625
+ */
626
+ export interface SettingsPlugin {
627
+ /**
628
+ * Opens the specified settings option on the current platform.
629
+ * On Web, this method is not supported.
630
+ *
631
+ * @param options Platform-specific settings options.
632
+ * @returns A promise resolving to the operation result.
633
+ *
634
+ * @since 1.0.0
635
+ */
636
+ open(options: PlatformOptions): Promise<SettingsResult>;
637
+ /**
638
+ * Opens a specific system settings section. (iOS Only)
639
+ *
640
+ * @platforms iOS
641
+ *
642
+ * @remarks
643
+ * Apple officially supports opening only the app-specific settings screen.
644
+ * Other settings destinations rely on undocumented URL schemes and may:
645
+ * - behave differently across iOS versions
646
+ * - stop working in future releases
647
+ * - be restricted during App Store review
648
+ *
649
+ * When unavailable, the method resolves with:
650
+ * `{ success: false, code: SettingsErrorCode.UNAVAILABLE }`.
651
+ *
652
+ * @param options iOS settings options.
653
+ * @returns A promise resolving to the operation result.
654
+ *
655
+ * @since 1.0.0
656
+ */
657
+ openIOS(options: IOSOptions): Promise<SettingsResult>;
658
+ /**
659
+ * Opens a specific Android Intent. (Android Only)
660
+ * On Web, this method is not supported.
661
+ *
662
+ * @platforms Android
663
+ *
664
+ * @param options Android settings options.
665
+ * @returns A promise resolving to the operation result.
666
+ *
667
+ * @since 1.0.0
668
+ */
669
+ openAndroid(options: AndroidOptions): Promise<SettingsResult>;
670
+ /**
671
+ * Returns the native plugin version.
672
+ *
673
+ * The returned version corresponds to the native implementation
674
+ * bundled with the application.
675
+ *
676
+ * @returns A promise resolving to the plugin version.
677
+ *
678
+ * @example
679
+ * ```ts
680
+ * const { version } = await Settings.getPluginVersion();
681
+ * ```
682
+ *
683
+ * @since 1.0.0
684
+ */
685
+ getPluginVersion(): Promise<PluginVersionResult>;
686
+ }