GithubHelp home page GithubHelp logo

natalya-semenova / privacy-screen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from capacitor-community/privacy-screen

0.0 0.0 0.0 579 KB

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.

License: MIT License

JavaScript 2.71% Ruby 5.52% Objective-C 4.62% Java 24.06% TypeScript 16.22% Swift 46.88%

privacy-screen's Introduction


Privacy Screen

@capacitor-community/privacy-screen

Capacitor Privacy Screen Plugin


Introduction

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.

On Android, this plugin sets the FLAG_SECURE flag to treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
On iOS, this plugin hides the webview window when the app is no longer active and loses focus (UIApplicationWillResignActiveNotification) so that a gray screen is shown instead. It also prevents screenshots (a black screen will be captured).

Using the Camera Plugin

Disabling screenshots can interfere with plugins that hide the WebView like the Camera plugin. To avoid issues call disable before using a plugin and then enable after you are finished.

Maintainers

Maintainer GitHub Social
Robin Genz robingenz @robin_genz

Installation

npm install @capacitor-community/privacy-screen
npx cap sync

Configuration

These configuration values are available:

Prop Type Description Default
enable boolean Configure whether the plugin should be enabled from startup. Only available for Android and iOS. true
imageName string Configure whether the plugin should display a custom image from assets instead of a default background gray for the privacy screen. Only available for iOS. ""

Examples

In capacitor.config.json:

{
  "plugins": {
    "PrivacyScreen": {
      "enable": true,
      "imageName": "Splashscreen"
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capacitor/privacy-screen" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    PrivacyScreen: {
      enable: true,
      imageName: "Splashscreen",
    },
  },
};

export default config;

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

The plugin only needs to be installed. The protection is enabled by default.
However, you have the option to enable/disable the protection:

import { PrivacyScreen } from '@capacitor-community/privacy-screen';

const enable = async () => {
  await PrivacyScreen.enable();
};

const disable = async () => {
  await PrivacyScreen.disable();
};

API

enable()

enable() => Promise<void>

Enables the privacy screen protection.

Only available for Android and iOS.

Since: 1.1.0


disable()

disable() => Promise<void>

Disables the privacy screen protection.

Only available for Android and iOS.

Since: 1.1.0


addListener('screenRecordingStarted', ...)

addListener(eventName: 'screenRecordingStarted', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the screen recording is started.

Only available on iOS for now.

Param Type
eventName 'screenRecordingStarted'
listenerFunc () => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 3.0.2


addListener('screenRecordingStopped', ...)

addListener(eventName: 'screenRecordingStopped', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the screen recording is stopped.

Only available on iOS for now.

Param Type
eventName 'screenRecordingStopped'
listenerFunc () => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 3.0.2


addListener('screenshotTaken', ...)

addListener(eventName: 'screenshotTaken', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the screenshot is taken.

Only available on iOS for now.

Param Type
eventName 'screenshotTaken'
listenerFunc () => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 3.2.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 3.0.2


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

Changelog

See CHANGELOG.md.

License

See LICENSE.

privacy-screen's People

Contributors

dtarnawsky avatar jcesarmobile avatar qliqdev avatar reinventit avatar robingenz avatar tripshade avatar ulricw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.