Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: iOS background prevent #43

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Setup
description: Setup Node.js and install dependencies
# name: Setup
# description: Setup Node.js and install dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
# runs:
# using: composite
# steps:
# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version-file: .nvmrc

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# - name: Cache dependencies
# id: yarn-cache
# uses: actions/cache@v3
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
yarn install --cwd example --frozen-lockfile
yarn install --frozen-lockfile
shell: bash
# - name: Install dependencies
# if: steps.yarn-cache.outputs.cache-hit != 'true'
# run: |
# yarn install --cwd example --frozen-lockfile
# yarn install --frozen-lockfile
# shell: bash
96 changes: 48 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: yarn lint

# - name: Typecheck files
# run: yarn typecheck

# test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Setup
# uses: ./.github/actions/setup

# - name: Run unit tests
# run: yarn test --maxWorkers=2 --coverage

# build:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Setup
# uses: ./.github/actions/setup

# - name: Build package
# run: yarn prepack
# name: CI
# on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main

# jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Setup
# uses: ./.github/actions/setup

# - name: Lint files
# run: yarn lint

# # - name: Typecheck files
# # run: yarn typecheck

# # test:
# # runs-on: ubuntu-latest
# # steps:
# # - name: Checkout
# # uses: actions/checkout@v3

# # - name: Setup
# # uses: ./.github/actions/setup

# # - name: Run unit tests
# # run: yarn test --maxWorkers=2 --coverage

# # build:
# # runs-on: ubuntu-latest
# # steps:
# # - name: Checkout
# # uses: actions/checkout@v3

# # - name: Setup
# # uses: ./.github/actions/setup

# # - name: Build package
# # run: yarn prepack
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

![Simulator Screen Recording](https://user-images.githubusercontent.com/37437842/206644553-e4c3f2bc-b624-47ac-a005-132199e049b2.gif)

![Simulator Screen Recording - iPhone 15 Pro - 2024-07-02 at 21 19 17](https://github.com/0xlethe/react-native-capture-protection/assets/37437842/ac98e942-8dba-4e5d-9f23-fa10f946b26b)

## Features

- iOS Capture Event via screen recording, capture capture with Listener
Expand Down
28 changes: 20 additions & 8 deletions example/0.73/src/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { StyleSheet, View, Button, Text } from 'react-native';
import {StyleSheet, View, Button, Text} from 'react-native';
import {
CaptureProtection,
CaptureProtectionModuleStatus,
useCaptureProtection,
} from 'react-native-capture-protection';
import { useNavigation } from '@react-navigation/native';
import {useNavigation} from '@react-navigation/native';
export default function Main() {
const { isPrevent, status } = useCaptureProtection();
const {isPrevent, status} = useCaptureProtection();
const navigation = useNavigation<any>();

React.useEffect(() => {
Expand All @@ -16,27 +16,27 @@ export default function Main() {
React.useEffect(() => {
console.log(
'Main Prevent Status is',
status ? CaptureProtectionModuleStatus?.[status] : undefined
status ? CaptureProtectionModuleStatus?.[status] : undefined,
);
}, [status]);

return (
<View style={styles.container}>
<Text style={{ color: isPrevent?.record ? 'blue' : 'black' }}>
<Text style={{color: isPrevent?.record ? 'blue' : 'black'}}>
{'Record Prevent : ' + isPrevent?.record}
</Text>
<Text style={{ color: isPrevent?.screenshot ? 'blue' : 'black' }}>
<Text style={{color: isPrevent?.screenshot ? 'blue' : 'black'}}>
{'Screenshot Prevent : ' + isPrevent?.screenshot}
</Text>
<Text style={{ color: 'black' }}>
<Text style={{color: 'black'}}>
{'Status : ' +
(status ? CaptureProtectionModuleStatus?.[status] : undefined)}
</Text>
<Button
title="set Record Protect Screen by Text"
onPress={() => {
CaptureProtection.setScreenRecordScreenWithText?.(
'This is Text Message!'
'This is Text Message!',
);
}}
/>
Expand Down Expand Up @@ -70,6 +70,18 @@ export default function Main() {
CaptureProtection.preventScreenshot();
}}
/>
<Button
title="allow background"
onPress={() => {
CaptureProtection.allowBackground();
}}
/>
<Button
title="prevent background"
onPress={() => {
CaptureProtection.preventBackground();
}}
/>
</View>
);
}
Expand Down
13 changes: 13 additions & 0 deletions example/under0.73/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ export default function Main() {
CaptureProtection.preventScreenshot();
}}
/>

<Button
title="allow background"
onPress={() => {
CaptureProtection.allowBackground();
}}
/>
<Button
title="prevent background"
onPress={() => {
CaptureProtection.preventBackground();
}}
/>
</View>
);
}
Expand Down
Loading