-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PM-15377: Rolled back review prompt legacy api #1218
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1218 +/- ##
==========================================
- Coverage 89.43% 89.41% -0.02%
==========================================
Files 692 693 +1
Lines 44080 44115 +35
==========================================
+ Hits 39423 39447 +24
- Misses 4657 4668 +11 ☔ View full report in Codecov by Sentry. |
No New Or Fixed Issues Found |
/// Requests a review of the app. | ||
private func requestReview() { | ||
if #available(iOS 16.0, *) { | ||
Environment(\.requestReview).wrappedValue() | ||
} else { | ||
SKStoreReviewController.requestReview() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 As stated in the previous PR, SKStoreReviewController has been deprecated in iOS 18. Ezimet had some problems with this so and we've also tried using a ViewModifier
with .apply()
+ #available
to include or not the view modifier but Ezimet said it was throwing some compiler issues.
@matt-livefront @KatherineInCode do you know any workaround for this so we can use the new environment approach for iOS 16+ and use the old approach for the older iOS version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it'd work but I've thought something like:
@available(iOS 16.0, *)
struct ReviewModifier: ViewModifier {
@Environment(\.requestReview) var requestReview
let afterClosure: () -> Void
func body(content: Content) -> some View {
content.onAppear {
requestReview()
afterClosure()
}
}
}
struct OldReviewModifier: ViewModifier {
let afterClosure: () -> Void
func body(content: Content) -> some View {
content.onAppear {
SKStoreReviewController.requestReview()
afterClosure()
}
}
}
And applying it like:
.apply { view in
if store.state.isEligibleForAppReview {
if #available(iOS 16.0, *) {
view.modifier(ReviewModifier(afterClosure: {
store.send(.appReviewPromptShown)
}))
} else {
view.modifier(OldReviewModifier(afterClosure: {
store.send(.appReviewPromptShown)
}))
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And another similar way:
@available(iOS 16.0, *)
struct ReviewModifier: ViewModifier {
@Environment(\.requestReview) var requestReview
let checkEligible: Bool
let afterClosure: () -> Void
func body(content: Content) -> some View {
content
.task(id: checkEligible) {
if checkEligible {
requestReview()
afterClosure()
}
}
}
}
struct OldReviewModifier: ViewModifier {
let checkEligible: Bool
let afterClosure: () -> Void
func body(content: Content) -> some View {
content
.task(id: checkEligible) {
if checkEligible {
SKStoreReviewController.requestReview()
afterClosure()
}
}
}
}
Applying like:
.apply { view in
if #available(iOS 16.0, *) {
view.modifier(ReviewModifier(checkEligible: store.state.isEligibleForAppReview, afterClosure: {
store.send(.appReviewPromptShown)
}))
} else {
view.modifier(OldReviewModifier(checkEligible: store.state.isEligibleForAppReview, afterClosure: {
store.send(.appReviewPromptShown)
}))
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second approach worked perfectly.
Thanks @fedemkr
🎟️ Tracking
PM-15377
📔 Objective
Environment(\.requestReview).wrappedValue()
was not actually working, so switched back to legacy apiSKStoreReviewController.requestReview()
.📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes