From b02e132a7557250901fb02570e162b730dc19793 Mon Sep 17 00:00:00 2001 From: noodleofdeath Date: Mon, 22 Jun 2026 09:47:26 -0400 Subject: [PATCH 1/3] Add App Store purchase restriction methods Expose deny/allow controls for in-app purchases and a setter for requiring a password for purchases, mapping to the iOS ManagedSettings appStore properties (denyInAppPurchases, requirePasswordForPurchases). The current values remain readable via getStore(). - iOS: write store.appStore.denyInAppPurchases / requirePasswordForPurchases - Android: persist flag state via SharedPreferences (no OS-level enforcement available for a regular app) - Document the new methods and note iOS-only enforcement in the README Co-Authored-By: Claude Opus 4.8 --- README.md | 19 +++++++++ .../screentimeapi/ScreenTimeAPIModule.java | 33 ++++++++++++++++ index.d.ts | 39 ++++++++++++++++++- .../ReactNativeScreenTimeAPI.m | 3 ++ .../ReactNativeScreenTimeAPI.swift | 17 +++++++- 5 files changed, 109 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c78b31..167bba5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Access the Screen Time API for iOS and Wellbeing API for Android (coming soon). - [Add FamilyControls capability to your app](#add-familycontrols-capability-to-your-app) - [Request Family Controls capabilities](#request-family-controls-capabilities) - [Set up for Expo](#set-up-for-expo) +- [App Store purchase restrictions](#app-store-purchase-restrictions) - [Sample code](#sample-code) - [Contributing](#contributing) - [Contributors](#contributors) @@ -110,6 +111,24 @@ Note: You'll need to install expo-build-properties if you haven't already: `expo install expo-build-properties` +## App Store purchase restrictions + +You can restrict App Store purchases through the following methods: + +```typescript +// in-app purchases +await ScreenTime.denyInAppPurchases(); // block in-app purchases +await ScreenTime.allowInAppPurchases(); // allow in-app purchases + +// require a password for purchases (pass a boolean) +await ScreenTime.requirePasswordForPurchases(true); +await ScreenTime.requirePasswordForPurchases(false); +``` + +On iOS these write to the corresponding [`ManagedSettings`](https://developer.apple.com/documentation/managedsettings/appstoresettings) `appStore` properties (`denyInAppPurchases` and `requirePasswordForPurchases`), and the current values can be read back from [`getStore()`](#sample-code) under `appStore`. + +> **⚠️ These restrictions are only enforced on iOS.** Android exposes no system-level API to restrict in-app purchases or require a password for purchases for a regular app, so on Android these methods only persist the flag state to mirror the API — they do not actually enforce any restriction. + ## Sample code ```typescript import React from 'react'; diff --git a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java index abfb413..f802d53 100644 --- a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java +++ b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java @@ -1,6 +1,8 @@ package com.noodleofdeath.screentimeapi; import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; import androidx.annotation.NonNull; @@ -16,10 +18,19 @@ public class ScreenTimeAPIModule extends ReactContextBaseJavaModule { private static final int REQUEST_CODE_ENABLE_ADMIN = 1; + private static final String PREFS_NAME = "ScreenTimeAPIPrefs"; + private static final String KEY_DENY_IN_APP_PURCHASES = "denyInAppPurchases"; + private static final String KEY_REQUIRE_PASSWORD_FOR_PURCHASES = "requirePasswordForPurchases"; + public ScreenTimeAPIModule(ReactApplicationContext reactContext) { super(reactContext); } + private SharedPreferences getPrefs() { + return getReactApplicationContext() + .getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); + } + @NonNull @Override public String getName() { @@ -76,4 +87,26 @@ public void allowAppInstallation(Promise promise) { promise.resolve("success"); } + // Android exposes no system-level in-app purchase restriction for a + // regular app, so the flags are only persisted here to mirror the iOS + // API; they are not enforced by the OS. + + @ReactMethod + public void denyInAppPurchases(Promise promise) { + getPrefs().edit().putBoolean(KEY_DENY_IN_APP_PURCHASES, true).apply(); + promise.resolve("success"); + } + + @ReactMethod + public void allowInAppPurchases(Promise promise) { + getPrefs().edit().putBoolean(KEY_DENY_IN_APP_PURCHASES, false).apply(); + promise.resolve("success"); + } + + @ReactMethod + public void requirePasswordForPurchases(boolean req, Promise promise) { + getPrefs().edit().putBoolean(KEY_REQUIRE_PASSWORD_FOR_PURCHASES, req).apply(); + promise.resolve("success"); + } + } \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 04da149..fd6c955 100644 --- a/index.d.ts +++ b/index.d.ts @@ -303,7 +303,44 @@ export type IScreenTimeAPI = { * @returns {Promise} */ allowAppRemoval: () => Promise; - + + /** + * Denies in-app purchases. + * + * On iOS this sets `ManagedSettingsStore.appStore.denyInAppPurchases = true`; + * the current value is readable via {@link getStore} (`appStore.denyInAppPurchases`). + * On Android the flag is persisted by this library (Android exposes no + * system-level in-app purchase restriction for a regular app). + * @platform ios + * @platform android + * @returns {Promise} + */ + denyInAppPurchases: () => Promise; + + /** + * Allows in-app purchases. + * + * On iOS this sets `ManagedSettingsStore.appStore.denyInAppPurchases = false`. + * On Android the flag is persisted by this library. + * @platform ios + * @platform android + * @returns {Promise} + */ + allowInAppPurchases: () => Promise; + + /** + * Sets whether a password is required for purchases. + * + * On iOS this sets `ManagedSettingsStore.appStore.requirePasswordForPurchases`; + * the current value is readable via {@link getStore} (`appStore.requirePasswordForPurchases`). + * On Android the flag is persisted by this library. + * @platform ios + * @platform android + * @param {boolean} req whether a password is required for purchases + * @returns {Promise} + */ + requirePasswordForPurchases: (req: boolean) => Promise; + /** * @platform ios * @returns {Promise} diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m index 1b29258..d0ac6f8 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m @@ -32,6 +32,9 @@ @interface RCT_EXTERN_MODULE(ScreenTimeAPI, NSObject) RCT_EXTERN_METHOD(allowAppRemoval) RCT_EXTERN_METHOD(denyAppInstallation) RCT_EXTERN_METHOD(allowAppInstallation) +RCT_EXTERN_METHOD(denyInAppPurchases) +RCT_EXTERN_METHOD(allowInAppPurchases) +RCT_EXTERN_METHOD(requirePasswordForPurchases: (BOOL) req) RCT_EXTERN_METHOD(displayFamilyActivityPicker: (NSDictionary *) options resolver: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift index dda6a2f..f860811 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift @@ -230,7 +230,22 @@ public class ScreenTimeAPI: NSObject { public func allowAppInstallation() { store.application.denyAppInstallation = false } - + + @objc + public func denyInAppPurchases() { + store.appStore.denyInAppPurchases = true + } + + @objc + public func allowInAppPurchases() { + store.appStore.denyInAppPurchases = false + } + + @objc + public func requirePasswordForPurchases(_ req: Bool) { + store.appStore.requirePasswordForPurchases = req + } + @objc public func initializeMonitoring(_ startTimestamp: String = "00:00", end endTimestamp: String = "23:59", From 3f98e975d80cb259c749a35098475ea4d01f5eee Mon Sep 17 00:00:00 2001 From: noodleofdeath Date: Mon, 22 Jun 2026 09:56:19 -0400 Subject: [PATCH 2/3] Match Apple AppStoreSettings API and deprecate allowInAppPurchases Apple's AppStoreSettings only exposes denyInAppPurchases and requirePasswordForPurchases (both Bool?), with no allow* counterpart. - denyInAppPurchases now takes a boolean matching the iOS property - allowInAppPurchases is deprecated (kept as a backwards-compatible alias for denyInAppPurchases(false)) - Document in JSDoc and JavaDoc that in-app purchase blocking and password-for-purchase are not supported on Android (no OS-level API) Co-Authored-By: Claude Opus 4.8 --- README.md | 16 +++++---- .../screentimeapi/ScreenTimeAPIModule.java | 30 +++++++++++++---- index.d.ts | 33 ++++++++++++------- .../ReactNativeScreenTimeAPI.m | 2 +- .../ReactNativeScreenTimeAPI.swift | 6 ++-- 5 files changed, 59 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 167bba5..1f8f128 100644 --- a/README.md +++ b/README.md @@ -113,21 +113,23 @@ Note: You'll need to install expo-build-properties if you haven't already: ## App Store purchase restrictions -You can restrict App Store purchases through the following methods: +These methods mirror Apple's [`ManagedSettings.AppStoreSettings`](https://developer.apple.com/documentation/managedsettings/appstoresettings) `appStore` properties, and each takes a boolean matching the corresponding property: ```typescript -// in-app purchases -await ScreenTime.denyInAppPurchases(); // block in-app purchases -await ScreenTime.allowInAppPurchases(); // allow in-app purchases +// in-app purchases (AppStoreSettings.denyInAppPurchases) +await ScreenTime.denyInAppPurchases(true); // block in-app purchases +await ScreenTime.denyInAppPurchases(false); // allow in-app purchases -// require a password for purchases (pass a boolean) +// require a password for purchases (AppStoreSettings.requirePasswordForPurchases) await ScreenTime.requirePasswordForPurchases(true); await ScreenTime.requirePasswordForPurchases(false); ``` -On iOS these write to the corresponding [`ManagedSettings`](https://developer.apple.com/documentation/managedsettings/appstoresettings) `appStore` properties (`denyInAppPurchases` and `requirePasswordForPurchases`), and the current values can be read back from [`getStore()`](#sample-code) under `appStore`. +On iOS the current values can be read back from [`getStore()`](#sample-code) under `appStore`. -> **⚠️ These restrictions are only enforced on iOS.** Android exposes no system-level API to restrict in-app purchases or require a password for purchases for a regular app, so on Android these methods only persist the flag state to mirror the API — they do not actually enforce any restriction. +> **`allowInAppPurchases()` is deprecated.** Apple's `AppStoreSettings` has no `allowInAppPurchases` property, so use `denyInAppPurchases(false)` instead. `allowInAppPurchases()` is kept only for backwards compatibility. + +> **⚠️ Not supported on Android.** Android exposes no system-level API to block in-app purchases or require a password for purchases for a regular app. These methods exist on Android only to mirror the API surface — they persist the flag state but do **not** enforce any restriction. ## Sample code ```typescript diff --git a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java index f802d53..4c547b1 100644 --- a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java +++ b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java @@ -87,22 +87,40 @@ public void allowAppInstallation(Promise promise) { promise.resolve("success"); } - // Android exposes no system-level in-app purchase restriction for a - // regular app, so the flags are only persisted here to mirror the iOS - // API; they are not enforced by the OS. - + // App Store purchase restrictions are not supported on Android: the OS + // exposes no system-level API to block in-app purchases or require a + // password for purchases for a regular app. The flags are only persisted + // here to mirror the iOS API; they are NOT enforced by the OS. + + /** + * Not supported on Android. In-app purchase blocking has no Android + * equivalent; the flag is persisted but never enforced by the OS. + */ @ReactMethod - public void denyInAppPurchases(Promise promise) { - getPrefs().edit().putBoolean(KEY_DENY_IN_APP_PURCHASES, true).apply(); + public void denyInAppPurchases(boolean deny, Promise promise) { + getPrefs().edit().putBoolean(KEY_DENY_IN_APP_PURCHASES, deny).apply(); promise.resolve("success"); } + /** + * Not supported on Android. In-app purchase blocking has no Android + * equivalent; the flag is persisted but never enforced by the OS. + * + * @deprecated Apple's {@code AppStoreSettings} has no {@code allowInAppPurchases} + * property; use {@link #denyInAppPurchases(boolean, Promise) denyInAppPurchases(false)} + * instead. Kept for backwards compatibility. + */ + @Deprecated @ReactMethod public void allowInAppPurchases(Promise promise) { getPrefs().edit().putBoolean(KEY_DENY_IN_APP_PURCHASES, false).apply(); promise.resolve("success"); } + /** + * Not supported on Android. Requiring a password for purchases has no + * Android equivalent; the flag is persisted but never enforced by the OS. + */ @ReactMethod public void requirePasswordForPurchases(boolean req, Promise promise) { getPrefs().edit().putBoolean(KEY_REQUIRE_PASSWORD_FOR_PURCHASES, req).apply(); diff --git a/index.d.ts b/index.d.ts index fd6c955..ee7b29c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -305,25 +305,31 @@ export type IScreenTimeAPI = { allowAppRemoval: () => Promise; /** - * Denies in-app purchases. + * Sets whether in-app purchases are denied. * - * On iOS this sets `ManagedSettingsStore.appStore.denyInAppPurchases = true`; - * the current value is readable via {@link getStore} (`appStore.denyInAppPurchases`). - * On Android the flag is persisted by this library (Android exposes no - * system-level in-app purchase restriction for a regular app). + * Mirrors Apple's + * [`AppStoreSettings.denyInAppPurchases`](https://developer.apple.com/documentation/managedsettings/appstoresettings/denyinapppurchases). + * On iOS this sets `ManagedSettingsStore.appStore.denyInAppPurchases`; the + * current value is readable via {@link getStore} (`appStore.denyInAppPurchases`). + * + * Not supported on Android — Android exposes no system-level API to block + * in-app purchases for a regular app, so this call has no effect there. * @platform ios - * @platform android + * @param {boolean} deny whether in-app purchases are denied * @returns {Promise} */ - denyInAppPurchases: () => Promise; + denyInAppPurchases: (deny: boolean) => Promise; /** * Allows in-app purchases. * - * On iOS this sets `ManagedSettingsStore.appStore.denyInAppPurchases = false`. - * On Android the flag is persisted by this library. + * @deprecated Apple's `AppStoreSettings` has no `allowInAppPurchases` + * property; use {@link denyInAppPurchases}`(false)` instead. Kept for + * backwards compatibility. + * + * Not supported on Android — Android exposes no system-level API to block + * in-app purchases for a regular app, so this call has no effect there. * @platform ios - * @platform android * @returns {Promise} */ allowInAppPurchases: () => Promise; @@ -331,11 +337,14 @@ export type IScreenTimeAPI = { /** * Sets whether a password is required for purchases. * + * Mirrors Apple's + * [`AppStoreSettings.requirePasswordForPurchases`](https://developer.apple.com/documentation/managedsettings/appstoresettings/requirepasswordforpurchases). * On iOS this sets `ManagedSettingsStore.appStore.requirePasswordForPurchases`; * the current value is readable via {@link getStore} (`appStore.requirePasswordForPurchases`). - * On Android the flag is persisted by this library. + * + * Not supported on Android — Android exposes no system-level API to require + * a password for purchases for a regular app, so this call has no effect there. * @platform ios - * @platform android * @param {boolean} req whether a password is required for purchases * @returns {Promise} */ diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m index d0ac6f8..0ccf6f8 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m @@ -32,7 +32,7 @@ @interface RCT_EXTERN_MODULE(ScreenTimeAPI, NSObject) RCT_EXTERN_METHOD(allowAppRemoval) RCT_EXTERN_METHOD(denyAppInstallation) RCT_EXTERN_METHOD(allowAppInstallation) -RCT_EXTERN_METHOD(denyInAppPurchases) +RCT_EXTERN_METHOD(denyInAppPurchases: (BOOL) deny) RCT_EXTERN_METHOD(allowInAppPurchases) RCT_EXTERN_METHOD(requirePasswordForPurchases: (BOOL) req) RCT_EXTERN_METHOD(displayFamilyActivityPicker: (NSDictionary *) options diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift index f860811..7cc1ecb 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift @@ -232,10 +232,12 @@ public class ScreenTimeAPI: NSObject { } @objc - public func denyInAppPurchases() { - store.appStore.denyInAppPurchases = true + public func denyInAppPurchases(_ deny: Bool) { + store.appStore.denyInAppPurchases = deny } + /// Deprecated: `AppStoreSettings` has no `allowInAppPurchases` property. + /// Use `denyInAppPurchases(false)` instead. Kept for backwards compatibility. @objc public func allowInAppPurchases() { store.appStore.denyInAppPurchases = false From 0ec2ac4b69466c3670897a976cdd8eed3ba7710b Mon Sep 17 00:00:00 2001 From: noodleofdeath Date: Mon, 22 Jun 2026 09:58:53 -0400 Subject: [PATCH 3/3] Match Apple ApplicationSettings API for app install/removal Apple's ApplicationSettings exposes denyAppInstallation and denyAppRemoval (both Bool?) with no allow* counterpart, mirroring the AppStoreSettings change. - denyAppInstallation / denyAppRemoval now take a boolean matching the iOS properties - allowAppInstallation / allowAppRemoval are deprecated (kept as backwards-compatible aliases for deny*(false)) Co-Authored-By: Claude Opus 4.8 --- .../screentimeapi/ScreenTimeAPIModule.java | 16 +++++++++-- index.d.ts | 28 +++++++++++++++++-- .../ReactNativeScreenTimeAPI.m | 4 +-- .../ReactNativeScreenTimeAPI.swift | 18 +++++++----- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java index 4c547b1..da858ee 100644 --- a/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java +++ b/android/src/main/java/com/noodleofdeath/screentimeapi/ScreenTimeAPIModule.java @@ -68,20 +68,32 @@ public void clearBlockedApplications(Promise promise) { } @ReactMethod - public void denyAppRemoval(Promise promise) { + public void denyAppRemoval(boolean deny, Promise promise) { promise.resolve("success"); } + /** + * @deprecated Apple's {@code ApplicationSettings} has no {@code allowAppRemoval} + * property; use {@link #denyAppRemoval(boolean, Promise) denyAppRemoval(false)} + * instead. Kept for backwards compatibility. + */ + @Deprecated @ReactMethod public void allowAppRemoval(Promise promise) { promise.resolve("success"); } @ReactMethod - public void denyAppInstallation(Promise promise) { + public void denyAppInstallation(boolean deny, Promise promise) { promise.resolve("success"); } + /** + * @deprecated Apple's {@code ApplicationSettings} has no {@code allowAppInstallation} + * property; use {@link #denyAppInstallation(boolean, Promise) denyAppInstallation(false)} + * instead. Kept for backwards compatibility. + */ + @Deprecated @ReactMethod public void allowAppInstallation(Promise promise) { promise.resolve("success"); diff --git a/index.d.ts b/index.d.ts index ee7b29c..677f07b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -277,13 +277,25 @@ export type IScreenTimeAPI = { clearBlockedApplications: () => Promise; /** + * Sets whether app installation is denied. + * + * Mirrors Apple's + * [`ApplicationSettings.denyAppInstallation`](https://developer.apple.com/documentation/managedsettings/applicationsettings/denyappinstallation). + * On iOS this sets `ManagedSettingsStore.application.denyAppInstallation`; the + * current value is readable via {@link getStore} (`application.denyAppInstallation`). * @platform ios * @platform android + * @param {boolean} deny whether app installation is denied * @returns {Promise} */ - denyAppInstallation: () => Promise; + denyAppInstallation: (deny: boolean) => Promise; /** + * Allows app installation. + * + * @deprecated Apple's `ApplicationSettings` has no `allowAppInstallation` + * property; use {@link denyAppInstallation}`(false)` instead. Kept for + * backwards compatibility. * @platform ios * @platform android * @returns {Promise} @@ -291,13 +303,25 @@ export type IScreenTimeAPI = { allowAppInstallation: () => Promise; /** + * Sets whether app removal is denied. + * + * Mirrors Apple's + * [`ApplicationSettings.denyAppRemoval`](https://developer.apple.com/documentation/managedsettings/applicationsettings/denyappremoval). + * On iOS this sets `ManagedSettingsStore.application.denyAppRemoval`; the + * current value is readable via {@link getStore} (`application.denyAppRemoval`). * @platform ios * @platform android + * @param {boolean} deny whether app removal is denied * @returns {Promise} */ - denyAppRemoval: () => Promise; + denyAppRemoval: (deny: boolean) => Promise; /** + * Allows app removal. + * + * @deprecated Apple's `ApplicationSettings` has no `allowAppRemoval` + * property; use {@link denyAppRemoval}`(false)` instead. Kept for + * backwards compatibility. * @platform ios * @platform android * @returns {Promise} diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m index 0ccf6f8..2a8abb2 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.m @@ -28,9 +28,9 @@ @interface RCT_EXTERN_MODULE(ScreenTimeAPI, NSObject) resolver: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) RCT_EXTERN_METHOD(clearActivitySelection) -RCT_EXTERN_METHOD(denyAppRemoval) +RCT_EXTERN_METHOD(denyAppRemoval: (BOOL) deny) RCT_EXTERN_METHOD(allowAppRemoval) -RCT_EXTERN_METHOD(denyAppInstallation) +RCT_EXTERN_METHOD(denyAppInstallation: (BOOL) deny) RCT_EXTERN_METHOD(allowAppInstallation) RCT_EXTERN_METHOD(denyInAppPurchases: (BOOL) deny) RCT_EXTERN_METHOD(allowInAppPurchases) diff --git a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift index 7cc1ecb..fabb510 100644 --- a/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift +++ b/ios/ReactNativeScreenTimeAPI/ReactNativeScreenTimeAPI.swift @@ -212,20 +212,24 @@ public class ScreenTimeAPI: NSObject { } @objc - public func denyAppRemoval() { - store.application.denyAppRemoval = true + public func denyAppRemoval(_ deny: Bool) { + store.application.denyAppRemoval = deny } - + + /// Deprecated: `ApplicationSettings` has no `allowAppRemoval` property. + /// Use `denyAppRemoval(false)` instead. Kept for backwards compatibility. @objc public func allowAppRemoval() { store.application.denyAppRemoval = false } - + @objc - public func denyAppInstallation() { - store.application.denyAppInstallation = true + public func denyAppInstallation(_ deny: Bool) { + store.application.denyAppInstallation = deny } - + + /// Deprecated: `ApplicationSettings` has no `allowAppInstallation` property. + /// Use `denyAppInstallation(false)` instead. Kept for backwards compatibility. @objc public func allowAppInstallation() { store.application.denyAppInstallation = false