Closed Phil0x11 closed 8 months ago
Unfortunately there are several problems with the screenshot feature. I may revert it (see https://github.com/capacitor-community/privacy-screen/issues/76#issuecomment-1776551316). However, PRs are welcome.
I encountered the same problem. Can't use disable().
My install packages on capacitor js.
"@capacitor-community/privacy-screen": "4.2.2", "@capacitor/android": "5.5.1", "@capacitor/cli": "5.5.1", "@capacitor/core": "5.5.1", "@capacitor/ios": "5.5.1",
please resolve problem
Thanks
I looked a little bit into that issue. It seems not all secure UITextField get removed on calling the enableScreenshots
method. I did not found a way to fix that yet.
What would the effect of reverting your last change be? Would it just stop working all together, or...? I see the same issue that disable doesn't work on iOS and that's quite a blocker at this point.
What would the effect of reverting your last change be?
Screenshots would no longer be prevented under iOS.
I'd be happy with removing the prevention on iOS, I'm more interested in event capture. Or even if you forked the plugin?
For some reason when the for of self.subviews, the items that are returned are not of type UITextField, I have a small modification and it seems to work, first I declare a secureTextFields variable of type array, and then in the addSecureText function I make an append field to the variable, and then when the enableScreenshots function is called it cycles through the array and not self.subviews, I attach screen I hope to help thanks
@rogomez-pricesmart Tested your solution, seems to work perfectly fine indeed! I'm curious if this approach could potentially cause memory leaks. I'm not very experienced with Swift, so I have no idea.
BTW: First of all thank you very much for your input! Secondly: never, ever share code by means of a screenshot ;) Just paste it as text or create a PR
For some reason when the for of self.subviews, the items that are returned are not of type UITextField, I have a small modification and it seems to work, first I declare a secureTextFields variable of type array, and then in the addSecureText function I make an append field to the variable, and then when the enableScreenshots function is called it cycles through the array and not self.subviews, I attach screen I hope to help thanks
It appears that the modification you made, where you declare a separate array secureTextFields to store the secure text fields and append to it in the addSecureText function, is causing a memory leak issue.
The reason for this memory leak is that when you append newField to secureTextFields, you're holding a strong reference to newField within the array. If you don't manage these references properly, it can lead to retain cycles, where objects reference each other and cannot be deallocated even when they are no longer needed.
To resolve this memory leak, you need to ensure that you properly manage the lifecycle of the UITextField instances stored in secureTextFields. This could involve removing references to them when they are no longer needed, such as when the corresponding view is removed from the superview or when the text fields themselves are deallocated.
Check pull request mention 😎🌷
Plugin version: 4.2.1
Platform(s): iOS
Current behavior: If I call the disable method the privacy screen will not be disabled in screenshots. I am still not able to screenshot the app.
Expected behavior: After calling the disable method, the privacy screen will be disabled.
Steps to reproduce:
Related code: https://github.com/Phil0x11/capacitor-privacy-screen-test
Capacitor doctor: Latest Dependencies:
@capacitor/cli: 5.5.1 @capacitor/core: 5.5.1 @capacitor/android: 5.5.1 @capacitor/ios: 5.5.1
Installed Dependencies:
@capacitor/android: not installed @capacitor/cli: 5.5.1 @capacitor/core: 5.5.1 @capacitor/ios: 5.5.1