capacitor-community / privacy-screen

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.
MIT License
88 stars 23 forks source link

Detect capturing in ios #51

Closed qliqdev closed 1 year ago

qliqdev commented 1 year ago

Created new branch for one feature detectCapturing

robingenz commented 1 year ago

I suggest we start with a simple Capacitor Plugin Event Listener for detecting screenshots and leave the functionality to the app:

/**
   * Listen for screen captures.
   * 
   * Only available on iOS.
   */
  addListener(
    eventName: 'capturingDetected',
    listenerFunc: () => void,
  ): Promise<PluginListenerHandle> & PluginListenerHandle;
  /**
   * Remove all listeners for this plugin.
   */
  removeAllListeners(): Promise<void>;

I can imagine that not every user of the plugin wants this functionality. Maybe screenshots should be allowed despite the current privacy screen.

qliqdev commented 1 year ago

Sure, let me fix it today.

qliqdev commented 1 year ago

Sure, let me fix it today.

Build fails. is project.pbxproj ok?

qliqdev commented 1 year ago

By the way should i change versions in package.json from 3.0.1 to 3.0.2?

robingenz commented 1 year ago

By the way should i change versions in package.json from 3.0.1 to 3.0.2?

No, thats not necessary.

robingenz commented 1 year ago

@qliqdev Thank you for your contribution!

bayasgalanpf commented 1 year ago

Thanks you, guys for doing this plugin.

i need "screenRecordingStarted" example code of JS version. help me. pls. i need detect screen recording on IOS.

my below code not working on iphone device.

PrivacyScreen.addEventListener( "screenRecordingStarted", function () { window.alert("Screen recording"); }, false );

Thanks.

qliqdev commented 1 year ago

Thanks you, guys for doing this plugin.

i need "screenRecordingStarted" example code of JS version. help me. pls.

i need detect screen recording on IOS.

my below code not working on iphone device.

**PrivacyScreen.addEventListener(

"screenRecordingStarted",

function () {

  window.alert("Screen recording");

},

false

);**

Thanks.

Which iOS version you are using?

bayasgalanpf commented 1 year ago

iOS version 16.0

qliqdev commented 1 year ago

iOS version 16.0

Looks like everything is ok.

this should be working

in your js/ts file:

await PrivacyScreen.addListener('screenRecordingStarted', async () => {
    document.documentElement.classList.toggle(`is-capturing`, true);
});
await PrivacyScreen.addListener('screenRecordingStopped', async () => {
    document.documentElement.classList.toggle(`is-capturing`, false);
});

in you global css file:

html.is-capturing{
  -webkit-filter: blur(20px);
  filter: blur(20px);
}
bayasgalanpf commented 1 year ago

Above code working.  👍 Thank you sir.