PHPackages                             codingwithrk/no-screenshot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. codingwithrk/no-screenshot

ActiveNativephp-plugin[Security](/categories/security)

codingwithrk/no-screenshot
==========================

A NativePHP Mobile plugin that prevents screenshots, blocks screen recording and global protection in App-switch state in your mobile app.

v1.0.0(2mo ago)10MITPHPPHP ^8.2

Since Mar 2Pushed 2mo agoCompare

[ Source](https://github.com/codingwithrk/no-screenshot)[ Packagist](https://packagist.org/packages/codingwithrk/no-screenshot)[ RSS](/packages/codingwithrk-no-screenshot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

NoScreenshot plugin for NativePHP Mobile
========================================

[](#noscreenshot-plugin-for-nativephp-mobile)

A NativePHP Mobile plugin that prevents screenshots, blocks screen recording and global protection in App-switch state in your mobile app.

Mainly useful for apps that handle sensitive data, such as `financial`, `healthcare`, or `enterprise applications`, where protecting user `privacy and data security` is paramount.

---

Platform Support
----------------

[](#platform-support)

FeatureAndroidiOSBlock screenshots✅⚠️ Detected, not preventableBlock screen recording✅✅ Black overlayDetect live recording—✅Global protection✅✅### How It Works

[](#how-it-works)

**Android** uses `WindowManager.LayoutParams.FLAG_SECURE` — an OS-level window flag that prevents the system from capturing the screen by any means: the screenshot button, the built-in screen recorder, ADB shell, and third-party capture apps all receive a blank or blocked frame.

**iOS** cannot prevent the system screenshot gesture at the application level. Instead the plugin:

- Observes `UIScreen.capturedDidChangeNotification`
- When recording starts and protection is active, immediately overlays a full-screen black `UIWindow` (above the status bar) that hides all WebView content
- Reports `isScreenBeingRecorded` in real time via `UIScreen.main.isCaptured`

---

Requirements
------------

[](#requirements)

MinimumPHP8.2NativePHP Mobile3.xAndroidAPI 21 (Android 5.0 Lollipop)iOS13.0> `FLAG_SECURE` is available from Android API 1. API 21 is the minimum set to match NativePHP Mobile's own requirements. The iOS 13 minimum is required because the recording overlay uses `UIWindowScene`, introduced in iOS 13.

---

Installation
------------

[](#installation)

```
composer require codingwithrk/no-screenshot
```

The service provider and `NoScreenshot` facade alias are auto-discovered by Laravel — no manual registration needed.

---

Quick Start
-----------

[](#quick-start)

```
use Codingwithrk\NoScreenshot\Facades\NoScreenshot;

// Protect the entire app
NoScreenshot::disableGlobally();

// Lift global protection
NoScreenshot::enableGlobally();
```

---

PHP API
-------

[](#php-api)

All methods are available via the `NoScreenshot` facade or by resolving `Codingwithrk\NoScreenshot\NoScreenshot` from the container.

### `disableGlobally(): bool`

[](#disableglobally-bool)

Activates protection for the entire app.

- **Android** — adds `FLAG_SECURE` to the activity window; all capture attempts receive a blank frame.
- **iOS** — registers the `UIScreen.capturedDidChangeNotification` observer; if recording is already in progress, the black overlay appears immediately.

Returns `true` on success, `false` if running outside NativePHP.

```
NoScreenshot::disableGlobally();
```

---

### `enableGlobally(): bool`

[](#enableglobally-bool)

Removes global protection.

```
NoScreenshot::enableGlobally();
```

---

### `toggle(): bool`

[](#toggle-bool)

Toggles global protection on/off. Returns the new `isGloballyProtected` state.

```
$isNowProtected = NoScreenshot::toggle();
```

---

### `getStatus(): ?ScreenProtectionStatus`

[](#getstatus-screenprotectionstatus)

Returns the current protection state as a typed DTO, or `null` outside NativePHP.

```
$status = NoScreenshot::getStatus();

$status->isGloballyProtected;         // bool — true after disableGlobally()
$status->isScreenBeingRecorded;       // bool — iOS: live UIScreen.main.isCaptured; Android: always false
$status->isScreenshotDetectionActive; // bool — true when screenshot detection is running
```

---

Events
------

[](#events)

Three events cover the full lifecycle of capture activity. Subscribe to them in your Livewire components or event listeners.

EventDispatched when`ScreenshotAttempted`A screenshot was taken (detected, cannot be blocked on iOS)`ScreenRecordingStarted``isScreenBeingRecorded` transitions `false → true``ScreenRecordingStopped``isScreenBeingRecorded` transitions `true → false`> **Android note:** `FLAG_SECURE` prevents capture rather than detecting it, so events are not dispatched automatically. Dispatch them manually from your polling logic if needed.

### Listening with `#[OnNative]`

[](#listening-with-onnative)

```
use Native\Mobile\Attributes\OnNative;
use Codingwithrk\NoScreenshot\Events\ScreenshotAttempted;
use Codingwithrk\NoScreenshot\Events\ScreenRecordingStarted;
use Codingwithrk\NoScreenshot\Events\ScreenRecordingStopped;

class MyLivewireComponent extends Component
{
    #[OnNative(ScreenshotAttempted::class)]
    public function onScreenshotAttempted(): void
    {
        // Log the attempt, notify the user, etc.
        logger()->warning('Screenshot attempted');
    }

    #[OnNative(ScreenRecordingStarted::class)]
    public function onRecordingStarted(): void
    {
        $this->dispatch('recording-started'); // trigger frontend update
    }

    #[OnNative(ScreenRecordingStopped::class)]
    public function onRecordingStopped(): void
    {
        $this->dispatch('recording-stopped');
    }
}
```

### Manual Dispatch from a Controller

[](#manual-dispatch-from-a-controller)

```
use Codingwithrk\NoScreenshot\Facades\NoScreenshot;
use Codingwithrk\NoScreenshot\Events\ScreenRecordingStarted;
use Codingwithrk\NoScreenshot\Events\ScreenRecordingStopped;
use Codingwithrk\NoScreenshot\Events\ScreenshotAttempted;

// In a controller action polled by the frontend:
$status = NoScreenshot::getStatus();

match (true) {
    $status->isScreenBeingRecorded => ScreenRecordingStarted::dispatch(),
    default                        => ScreenRecordingStopped::dispatch(),
};

ScreenshotAttempted::dispatch();
```

---

ScreenProtectionStatus Reference
--------------------------------

[](#screenprotectionstatus-reference)

PropertyTypeAndroidiOS`isGloballyProtected``bool`✅✅`isScreenBeingRecorded``bool`Always `false`Live `UIScreen.main.isCaptured``isScreenshotDetectionActive``bool`API 34+ only✅ All versions---

Platform Notes
--------------

[](#platform-notes)

### Android — `min_sdk_version: 21`

[](#android--min_sdk_version-21)

- `FLAG_SECURE` has been available since API 1, but NativePHP Mobile itself targets API 21+.
- The flag covers the **entire activity window** — all capture attempts (screenshot button, built-in recorder, ADB, third-party apps) receive a blank frame.
- The flag also hides the app thumbnail in the **Recents / App Switcher**.
- Screenshot *detection* via `registerScreenCaptureCallback` requires API 34+. On older devices, `startScreenshotDetection()` returns `supported: false` and no events fire.

### iOS — `min_version: 13.0`

[](#ios--min_version-130)

- **iOS 13** is the minimum because the recording overlay uses `UIWindowScene`, which was introduced in iOS 13.
- `UIScreen.main.isCaptured` (available iOS 11+) is `true` during screen recording **and** AirPlay mirroring — the overlay appears in both cases.
- **Screenshots cannot be prevented** at the application level. The image is saved to Photos before the notification fires. The plugin can detect attempts via `UIApplication.userDidTakeScreenshotNotification` and dispatch `ScreenshotAttempted`, but the file is already saved by then.
- The black overlay is a `UIWindow` at `UIWindow.Level.statusBar + 1`, placed above all app content including the NativePHP WebView.

---

Testing
-------

[](#testing)

### Device / simulator testing

[](#device--simulator-testing)

```
# Install in your NativePHP app (uses path repository)
composer require codingwithrk/no-screenshot

# Run on Android
php artisan native:run android

# Run on iOS
php artisan native:run ios
```

Then trigger `NoScreenshot::disableGlobally()` from a controller or Livewire component and:

**Android** — press the screenshot button. The OS shows "Can't take screenshot due to security policy."

**iOS** — start a screen recording from Control Center. The black overlay should appear immediately and disappear when recording stops.

---

Support
-------

[](#support)

For questions or issues, email

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

77d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bb4ef593bedabe28ed3c56ee0af1e397428363e05236552b7de1fcdd4da5d93?d=identicon)[CodingwithRK](/maintainers/CodingwithRK)

---

Top Contributors

[![codingwithrk](https://avatars.githubusercontent.com/u/107883290?v=4)](https://github.com/codingwithrk "codingwithrk (2 commits)")

---

Tags

nativephpnativephp-mobilenativephp-plugin

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/codingwithrk-no-screenshot/health.svg)

```
[![Health](https://phpackages.com/badges/codingwithrk-no-screenshot/health.svg)](https://phpackages.com/packages/codingwithrk-no-screenshot)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
