capacitor-community / privacy-screen

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

feat: alternative foreground/background events #108

Open TiBz0u opened 2 months ago

TiBz0u commented 2 months ago

Is your feature request related to a problem? Please describe:

Hi,

We are using your plugin since few months and we discover a difference between the behavior from Cordova to Capacitor implementation.

In our new Capacitor application, when we try to open a phone number or start biometric, the privacy screen starts (grey screen or splash image). That's very confusing for the users.

We discover it's linked to the event used into the plugin.

For Cordova, we were using a fork of the cordova-plugin-privacyscreen in which the events were replaced :

https://github.com/jayj/cordova-plugin-privacyscreen/commit/6a29d66a6b7e9d45797ea6b704599b8ac4cd5e63

With this implementation, the event is triggered at the right moment. However, at the moment, the viewController doesn't seem to be shown correctly (I'm currently trying to fix it, but not expert in swift).

Describe the solution you'd like:

A parameter that permit to switch between activeNotificationEvent and foregroundBackgroundNotificationEvent.

Describe alternatives you've considered:

Create a fork of the plugin....

Additional context:

robingenz commented 2 months ago

Can you record two screen videos with the behavior before and after? I'd like to take a look at it. Basically, I have nothing against this change.

TiBz0u commented 2 months ago

hi @robingenz , Thanks for your fast reply. I'll try to generate a video soon. I need to anonymise the application first.

Meanwhile, you can easily reproduce by having a link/button that makes a call

<a href="tel:+xx xxx xxx">call</a>

On iOS, you'll have a small pop-up at the bottom on the application and the application will be hidden by the grey screen (privacy). With the other events, app is still visible. example : image

Kr.

robingenz commented 1 month ago

Thanks, i need to test this myself. I will get back to you.

However, at the moment, the viewController doesn't seem to be shown correctly (I'm currently trying to fix it, but not expert in swift).

Does this problem also occur in the current implementation?

TiBz0u commented 1 month ago

Hi @robingenz , If I only change the event type on the current implementation (version 5.2.1), it doesn't work anymore. Kr.

robingenz commented 1 month ago

Okay, we need to fix that before we can merge it. I would then suggest that we add a configuration option so that you can choose the behavior.

TiBz0u commented 2 weeks ago

Hi @robingenz,

FYI, I have succeeded to have a working result.

However, I had to rewrite the system for showing the "Privacy Controller" by using a new UIWindow. It's more readable that the current implementation with Scene/ViewController. Will be certainly one of the main subject of discussion.

I took inspiration from the following example.

I still need to make some tests.

After my testing, I'll make a PR like this we can discuss on it.

Kr.