Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ezimet-livefront
Copy link
Collaborator

@ezimet-livefront ezimet-livefront commented Dec 18, 2024

🎟️ Tracking

PM-15377

📔 Objective

  • the previous Environment(\.requestReview).wrappedValue() was not actually working, so switched back to legacy api SKStoreReviewController.requestReview().

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 53.06122% with 23 lines in your changes missing coverage. Please review.

Project coverage is 89.41%. Comparing base (625bbd3) to head (5f51298).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...lication/Appearance/Modifiers/ReviewModifier.swift 47.50% 21 Missing ⚠️
...hared/UI/Vault/Vault/VaultList/VaultListView.swift 33.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 18, 2024

Logo
Checkmarx One – Scan Summary & Details0f59d8b3-8dba-4557-ac58-8fc66262bbd7

No New Or Fixed Issues Found

Comment on lines -384 to -391
/// Requests a review of the app.
private func requestReview() {
if #available(iOS 16.0, *) {
Environment(\.requestReview).wrappedValue()
} else {
SKStoreReviewController.requestReview()
}
}
Copy link
Member

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?

Copy link
Member

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)
            }))
        }
    }
}

Copy link
Member

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)
        }))
    }
}

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants