There are some new environment variable I need to use, for example
@Environment(.requestReview) var requestReview // StoreKit
But my app needs to support older iOS. How do I "wrap" around this environment variable while not using iOS 16?
There are some new environment variable I need to use, for example
@Environment(.requestReview) var requestReview // StoreKit
But my app needs to support older iOS. How do I "wrap" around this environment variable while not using iOS 16?
3
Answers
We need to annotate view holding that, like
You can create your own extension for
EnvironmentValues
& in it do the check:I wish I could come up with a more idiomatic solution that would promote the usage of
@Environment
variables as the original API does, but declaring a newViewModifier
does the trick.Start by declaring a new
ViewModifier
, followed by its extension, to make it available onView
:You can then use it as follows: