Download the PHP package codingwithrk/no-screenshot without Composer

On this page you can find all versions of the php package codingwithrk/no-screenshot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package no-screenshot

NoScreenshot plugin for NativePHP Mobile

Latest Version Packagist Downloads License

A NativePHP Mobile plugin that prevents screenshots, blocks screen recording, and protects the App Switcher thumbnail — on both Android and iOS.

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

Feature Android iOS
Block screenshots ✅ FLAG_SECURE ✅ UITextField secure layer
Block screen recording ✅ FLAG_SECURE ✅ Black overlay
App Switcher thumbnail protection ✅ ✅
Detect live recording — ✅ UIScreen.isCaptured
Detect screenshot events ✅ API 34+ ✅ All versions
Persist protection across restarts ✅ ✅

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, and third-party capture apps all receive a blank frame. The flag also prevents the App Switcher / Recents thumbnail from showing real content.

A ContentProvider (NoScreenshotInitProvider) registers Application.ActivityLifecycleCallbacks before any Activity is created. On every Activity.onCreate() it reads the persisted protection state from SharedPreferences and re-applies FLAG_SECURE — so the flag is active from the very first frame, even before the WebView or any PHP controller has run.

iOS uses two complementary techniques:

  1. UITextField isSecureTextEntry screenshot prevention — when protection is active, all main-window content is moved inside the first subview of a UITextField with isSecureTextEntry = true. iOS routes that subtree through its system DRM compositing path, which is excluded from the screenshot pipeline. The protected area appears blank/white in any screenshot taken while protection is active.

  2. Overlay windows — a full-screen black UIWindow (above the status bar) is shown:
    • When UIScreen.main.isCaptured is true (screen recording / AirPlay mirroring active)
    • When UIApplication.willResignActiveNotification fires (user pressed Home — prevents the OS from capturing a real frame for the App Switcher thumbnail)

Protection state is persisted in UserDefaults. The plugin exports a NativePHPNoScreenshotInit function (registered as init_function in the manifest) that restores the saved state at app startup, re-arming all observers before the first bridge call.


Requirements

Minimum
PHP 8.2
NativePHP Mobile 3.x or 4.x
Android API 21 (Android 5.0 Lollipop)
iOS 13.0

FLAG_SECURE is available from Android API 1. API 21 is set to match NativePHP Mobile's own minimum. The iOS 13 minimum is required because the recording overlay uses UIWindowScene, introduced in iOS 13.


Installation

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


Quick Start

Call disableGlobally() once — from a service provider, middleware, or any controller. The choice is saved to SharedPreferences (Android) / UserDefaults (iOS) and automatically restored the next time the app launches.


PHP API

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

disableGlobally(): bool

Activates protection for the entire app and persists the state so it survives app restarts.

Returns true on success, false if running outside NativePHP.


enableGlobally(): bool

Removes global protection and clears the persisted state.


toggle(): bool

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


getStatus(): ?ScreenProtectionStatus

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


startScreenshotDetection(): bool

Registers a native observer that fires ScreenshotAttempted whenever the user takes a screenshot.


stopScreenshotDetection(): bool

Unregisters the screenshot observer.


Events

Three events cover the full lifecycle of capture activity. Listen to them in Livewire components with the native: prefix.

Event Dispatched when
ScreenshotAttempted A screenshot was taken (iOS: all versions; Android: API 34+)
ScreenRecordingStarted isScreenBeingRecorded transitions false → true (iOS)
ScreenRecordingStopped isScreenBeingRecorded transitions true → false (iOS)

Android note: FLAG_SECURE prevents capture at the OS level rather than detecting it. ScreenshotAttempted requires API 34+ and startScreenshotDetection() to be called first. ScreenRecordingStarted / ScreenRecordingStopped are iOS-only.

Listening in a Livewire component

Manual dispatch (polling pattern)


ScreenProtectionStatus Reference

Property Type Android iOS
isGloballyProtected bool ✅ ✅
isScreenBeingRecorded bool Always false Live UIScreen.main.isCaptured
isScreenshotDetectionActive bool API 34+ only ✅ All versions

Platform Notes

Android

iOS


Testing

Unit tests

Device scenarios

# Scenario Steps Expected
1 App Switcher (Android & iOS) Enable protection → press Home → open Recents Thumbnail is black
2 Screenshot content (iOS) Enable protection → take screenshot (Vol Up + Side) → open Photos Screenshot is blank/white
3 Screenshot event (Android 14+ & iOS) startScreenshotDetection() → take screenshot ScreenshotAttempted fires in Livewire
4 Restart persistence (Android & iOS) Enable protection → force-kill app → reopen Protection active before any PHP call; App Switcher thumbnail already black

Changelog

1.1.0

1.0.0


Support

For questions or issues, email [email protected]

License

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


All versions of no-screenshot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
nativephp/mobile Version ^3.0|^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codingwithrk/no-screenshot contains the following files

Loading the files please wait ...