cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
546 stars 656 forks source link

[screen_state] iOS support and renewal of the native example apps #901

Closed luansilva-tokenlab closed 2 months ago

luansilva-tokenlab commented 7 months ago

I introduced iOS support to the 'screen_state' package by leveraging the 'isProtectedDataAvailable' and 'brightness' parameters for screen state analysis. Additionally, I refined the base plugin to facilitate its utilization in iOS applications, and optimized code readability and data handling with enhanced enums.

Moreover, I updated the native example apps using Flutter 3.16.9 as the foundation, addressing their outdated status and ensuring compatibility with iOS.

Despite these advancements, I encountered limitations inherent to the iOS platform. Notably, the 'isProtectedDataAvailable' parameter only provides data if the user has any form of password protection enabled, rendering it ineffective for detecting unlocks on devices without a password. Furthermore, the iOS simulator's inability to replicate device locking behavior and its distinct brightness controls hampered event detection within the simulator environment.

Throughout development, I conducted testing on an iPhone 6+ running iOS 12.5.7, successfully capturing all relevant events.

luansilva-tokenlab commented 7 months ago

169

bardram commented 6 months ago

This looks indeed interesting. I will take a look later.

SlimShadyIAm commented 2 months ago

Hi @luansilva-tokenlab, thanks for your PR - this all looks great!

I noticed that due to your approach of using brightness to detect whether the screen is on or off, if the user changes their brightness slider to the lowest setting, it generates a SCREEN_OFF event. This seems unavoidable to me, so it might be worth mentioning this in the limitations - do you agree?

luansilva-tokenlab commented 2 months ago

Hi @luansilva-tokenlab, thanks for your PR - this all looks great!

I noticed that due to your approach of using brightness to detect whether the screen is on or off, if the user changes their brightness slider to the lowest setting, it generates a SCREEN_OFF event. This seems unavoidable to me, so it might be worth mentioning this in the limitations - do you agree?

I believe so. I didn't encounter this behavior during my tests, but I imagine it could vary between iOS versions, as I tested with an iPhone 7 running iOS 15 and an iPhone 6+ running iOS 12.

SlimShadyIAm commented 2 months ago

Got it - thanks!

In your testing, is the app able to continuously record screen events when running in the background indefinitely? And do you foresee any issues for any apps that depend on the package when going through the App Store review process with this approach?

luansilva-tokenlab commented 2 months ago

Got it - thanks!

In your testing, is the app able to continuously record screen events when running in the background indefinitely? And do you foresee any issues for any apps that depend on the package when going through the App Store review process with this approach?

Yes, it was able to run during my tests, capturing events for up to three consecutive days without any issues. I believe this shouldn't cause any problems with the AppStore, as it is simply an analysis of features offered by Apple itself.

SlimShadyIAm commented 2 months ago

Wonderful, thanks for your contribution :)