diff --git a/android/src/main/java/com/captureprotection/CaptureProtectionModule.java b/android/src/main/java/com/captureprotection/CaptureProtectionModule.java index 4005e05..f651bb9 100644 --- a/android/src/main/java/com/captureprotection/CaptureProtectionModule.java +++ b/android/src/main/java/com/captureprotection/CaptureProtectionModule.java @@ -118,8 +118,8 @@ private boolean requestStoragePermission() { // android.permission.DETECT_SCREEN_CAPTURE instead. } - String requestPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU - ? Manifest.permission.READ_MEDIA_IMAGES + String requestPermission = Build.VERSION.SDK_INT >= 33 // Build.VERSION_CODES.TIRAMISU + ? "android.permission.READ_MEDIA_IMAGES" // Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE; if (ContextCompat.checkSelfPermission( @@ -213,6 +213,16 @@ public String getName() { return NAME; } + @ReactMethod + public void addListener(String eventName) { + addListener(); + } + + @ReactMethod + public void removeListeners(Integer count) { + removeListener(); + } + @ReactMethod public void addScreenshotListener() { addListener(); diff --git a/example/android/build.gradle b/example/android/build.gradle index 8569fee..355f3b0 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -4,8 +4,8 @@ buildscript { ext { buildToolsVersion = "31.0.0" minSdkVersion = 21 - compileSdkVersion = 31 - targetSdkVersion = 31 + compileSdkVersion = 32 + targetSdkVersion = 32 if (System.properties['os.arch'] == "aarch64") { // For M1 Users we need to use the NDK 24 which added support for aarch64 diff --git a/package.json b/package.json index 6c90ecc..bb7e701 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-capture-protection", - "version": "1.9.2", + "version": "1.9.3", "description": "It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -83,7 +83,7 @@ "engines": { "node": ">= 16.0.0" }, - "packageManager": "^yarn@1.22.15", + "packageManager": "^yarn@1.22.21", "jest": { "preset": "react-native", "modulePathIgnorePatterns": [ diff --git a/src/index.tsx b/src/index.tsx index d72ab65..d613831 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -52,6 +52,8 @@ function addEventListener(callback: CaptureEventListenerCallback): void { if (Platform.OS !== 'ios' && Platform.OS !== 'android') { return; } + addScreenshotListener(); + addScreenRecordListener(); CaptureNotificationEmitter?.addListener?.( CaptureProtectionEventType, callback @@ -210,7 +212,7 @@ const removeScreenshotListener = async (): Promise => { * * return listener regist status * - * if `android`, recording status is always return `false` */ + */ const hasListener = async (): Promise => { if (Platform.OS === 'android') { return await CaptureProtectionModule?.hasListener?.(); @@ -421,25 +423,10 @@ export const CaptureProtection = { preventScreenshot, allowScreenRecord, preventScreenRecord, - /** - * @deprecated - */ addScreenshotListener, - /** - * @deprecated - */ removeScreenshotListener, - /** - * @deprecated - */ addScreenRecordListener, - /** - * @deprecated - */ removeScreenRecordListener, - /** - * @deprecated - */ hasListener, isScreenRecording, requestPermission,