Pavel Alexeev
Pavel Alexeev

Reputation: 6081

How to tell if Live Activity is visible to user (with the screen turned on)

I'm working on a fitness tracker app and want to update long-running Live Activity frequently — once per second.
But I also want to keep the battery usage low and don't want to calculate stats and everything when user won't see it.

I know I can see app's current Live Activities using Activity.activities.
Is there are any way to tell if iPhone is not in user's pocket, its screen is on (with always on display or not) and it's really worth updating Live Activity?

Upvotes: 0

Views: 500

Answers (1)

jakub1984
jakub1984

Reputation: 114

You can check SwiftUI’s isLuminanceReduced environment value to detect reduced luminance.

Upvotes: 0

Related Questions