定制 macrotom/screen-privacy 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

macrotom/screen-privacy

最新稳定版本:v1.0.0

Composer 安装命令:

composer require macrotom/screen-privacy

包简介

Prevent screenshots and screen recordings using native platform protections for NativePHP Mobile

README 文档

README

Prevent screenshots and screen recordings of sensitive content using native platform protections (FLAG_SECURE on Android, secure overlay on iOS).

Installation

composer require macrotom/screen-privacy

Usage

PHP (Livewire/Blade)

use MacroTom\ScreenPrivacy\Facades\ScreenPrivacy;

// Initialize screen privacy (registers callbacks on Android 14+)
ScreenPrivacy::init();

// Enable screen privacy protection
ScreenPrivacy::enable();

// Disable screen privacy protection
ScreenPrivacy::disable();

// Check if screen privacy is currently active
$isEnabled = ScreenPrivacy::isEnabled(); // returns bool

// Check if the screen is being recorded (iOS only)
$isRecording = ScreenPrivacy::isRecording(); // returns bool

JavaScript (Vue/React/Inertia)

import { screenPrivacy } from '@macrotom/screen-privacy';

// Initialize on mount
await screenPrivacy.init();

// Enable/disable protection
await screenPrivacy.enable();
await screenPrivacy.disable();

// Check status
const enabled = await screenPrivacy.isEnabled();
const recording = await screenPrivacy.isRecording();

Events

use Native\Mobile\Attributes\OnNative;
use MacroTom\ScreenPrivacy\Events\ScreenCaptureDetected;
use MacroTom\ScreenPrivacy\Events\ScreenRecordingDetected;
use MacroTom\ScreenPrivacy\Events\ScreenPrivacyEnabled;
use MacroTom\ScreenPrivacy\Events\ScreenPrivacyDisabled;

#[OnNative(ScreenCaptureDetected::class)]
public function handleScreenCapture()
{
    // A screenshot attempt was detected
}

#[OnNative(ScreenRecordingDetected::class)]
public function handleScreenRecording(bool $isRecording)
{
    // Screen recording started or stopped
}

#[OnNative(ScreenPrivacyEnabled::class)]
public function handlePrivacyEnabled()
{
    // Screen privacy was enabled
}

#[OnNative(ScreenPrivacyDisabled::class)]
public function handlePrivacyDisabled()
{
    // Screen privacy was disabled
}

Platform Behavior

Feature Android iOS
Screenshot blocking FLAG_SECURE (hardware-level) Secure overlay via UITextField
Screenshot detection Android 14+ (API 34) callback userDidTakeScreenshotNotification
Recording detection Not supported (returns false) UIScreen.isCaptured
Minimum version API 26 iOS 13.0

Important Notes

  • Call init() once during app initialization before using other methods.
  • Android uses FLAG_SECURE which hardware-blocks all screen captures while enabled.
  • iOS detects screenshots after they occur and applies a secure overlay to block recordings.
  • Screen recording detection (isRecording()) is only available on iOS. On Android it always returns false.

License

MIT

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固