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

[CustomerCenter] Open App Store when the user wants to update their app #4199

Merged
merged 118 commits into from
Aug 27, 2024

Conversation

JayShortway
Copy link
Member

@JayShortway JayShortway commented Aug 19, 2024

AppUpdateWarningView opens the App Store when the user clicks Update.

vegaro and others added 30 commits July 17, 2024 11:21
Base branch is `integration/customer_support_workflow` so we don't merge
into `main` yet

Borrows a lot from #3865

Creates a new `CustomerCenterView` that can be used as a customer
support workflow starting point.

All details can be found in
https://linear.app/revenuecat/project/sdk-support-workflow-cf7f6a1d5340/overview

---------

Co-authored-by: Will Taylor <wtaylor151@gmail.com>
Co-authored-by: James Borthwick <109382862+jamesrb1@users.noreply.github.com>
Adds `Purchases.shared.loadCustomerCenter()` that calls a new backend
endpoint that returns the customer center configuration

This API call doesn't exist yet and it will change. This PR is the
ground work so that we don't have to wait for the backend to add this
API and we can already pretend the API is there.

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
Based off #3933 



https://github.com/RevenueCat/purchases-ios/assets/664544/11eae984-294a-4e14-8c40-7c2d50994c09

Can probably use some animations, but tuning that up will come up later

It will open a feedback survey for an option if there's one
### Description
This adds a modifier, `presentCustomerCenter` that can be used to more
simply display the customer center. The API looks like:
```
.presentCustomerCenter(isPresented: self.$presentingCustomerCenter) {
    self.presentingCustomerCenter = false
}
```
### Description
This PR provides a possible approach to implementing an "action"
handler. This allows developer to respond to events that happen during
the customer support flow.

The current approach consists of making `CustomerCenterActionHandler`, a
lambda that receives an action that can be passed in by the developer.
Then calling that with the appropriate action from the customer center.
This PR also moves some code to the view model for simplicity and moving
logic away from the view layer.
Adds displaying a Promotional Offer if the path has an offer id
configured

---------

Co-authored-by: JayShortway <29483617+JayShortway@users.noreply.github.com>
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
### Description
This is based on the changes in #3968 

This PR:
- Moves the strings currently hardcode into the
`CustomerCenterConfigData.Localization` object.
- Fixes an issue compiling paywall tester introduced in a previous PR
- Modifies how we read backend strings to not account for the `common_`
prefix, which is already removed by the backend.
Builds buttons from the Appearance object in the JSON
I think this comes from a bad merge, because this project doesn't touch
that file. Xcode is automatically cleaning it up
Add contact support button to the `ManageSubscriptionsView`

---------

Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
We were not checking if the user is eligible for the promotional offer
before trying to load it
- Adapt changes from RevenueCat/khepri#9707
which makes colors nullable and adds new colors for buttons
- Change background and text color in all screens
- Modified buttons to use `.buttonStyle(.borderedProminent)` so they
look native by default
- Applied accent color to back button in navigation view
I noticed the purchase button for the promo offers is always disabled.
Changing the order of the modifiers fixes it
The subscription details view could take advantage of more available
space

- expands details view
- increases font sizes
- wraps in a scrollview for smaller screen sizes
- softens shadow
- have buttons fill available space, limit width via container views

| New           | Old           |
|:-------------:|:-------------:|
| ![New
Version](https://github.com/user-attachments/assets/27c4a7fd-60be-4536-b88c-b2c9c6141c8f)
| ![Old
Version](https://github.com/user-attachments/assets/9bd80877-4fa6-4c7e-a813-5e7a3c1bbcc2)
|
@JayShortway JayShortway marked this pull request as ready for review August 26, 2024 11:50
Copy link
Contributor

@jamesrb1 jamesrb1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! Just one minor item to consider.

ManageSubscriptionsView(screen: screen,
customerCenterActionHandler: viewModel.customerCenterActionHandler)
} else {
AppUpdateWarningView(
onUpdateAppClick: { viewModel.onAppUpdateClick() },
productId: configuration.productId!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently safe given the code above, but changes above could render it un-safe. I would recommend turning the else into an else if let statement which can be used to safely unwrap productId, and then have an else block that displays maybe content unavailable and logs an error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a good point. I was a bit conflicted about this as I didn't want to add an entire view just because the compiler isn't able to figure out that productId is actually nil here.

I ended up inverting the if statement, so the productId is safely unwrapped in the initial condition. This avoids a useless view and keeps the compiler happy. See a55224e.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was surprised to see how in Kotlin the null check meant that the compiler now knew it was non-null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea smart casts are amazing, and they got even better in Kotlin 2 (which we're not using anywhere yet though).

Base automatically changed from ui-latest-version to main August 27, 2024 08:07
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@JayShortway JayShortway enabled auto-merge (squash) August 27, 2024 11:36
@JayShortway JayShortway merged commit 2a6def5 into main Aug 27, 2024
5 checks passed
@JayShortway JayShortway deleted the open-app-store branch August 27, 2024 11:43
vegaro pushed a commit that referenced this pull request Aug 30, 2024
**This is an automatic release.**

### Bugfixes
* Fix `compatibleTopBarTrailing` in MacOS and api tests (#4226) via
Cesar de la Vega (@vegaro)
* [Paywall] Fix restoreStarted not being called on
`presentPaywallIfNeeded` when using `requiredEntitlementIdentifier`
(#4223) via Josh Holtz (@joshdholtz)
* [CustomerCenter] Move sheet and restore alert creation to
`ManageSubscriptionsView` (#4220) via Cesar de la Vega (@vegaro)
* [EXTERNAL] `Custom Entitlements Computation`: fix support display on
debug screen (#4215) by @NachoSoto (#4218) via Toni Rico (@tonidero)
* [Customer Center] Add padding to `No thanks` in promotional offer
screen (#4221) via Cesar de la Vega (@vegaro)
* Fix version number in plist files (#4213) via Cesar de la Vega
(@vegaro)
* fix mac os sandbox check slowness (#3879) via Andy Boedo (@aboedo)
* [Customer Center] Fix `FeedbackSurveyView` not opening (#4208) via
Cesar de la Vega (@vegaro)
* Remove `unneeded_override` disable to fix linter (#4209) via Cesar de
la Vega (@vegaro)
### Dependency Updates
* Bump rexml from 3.3.3 to 3.3.6 in
/Tests/InstallationTests/CocoapodsInstallation (#4210) via
dependabot[bot] (@dependabot[bot])
* Bump rexml from 3.3.3 to 3.3.6 (#4211) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* Update readme wording (#3914) via James Borthwick (@jamesrb1)
* Set a maximum duration for iOS 15 tests (#4229) via Cesar de la Vega
(@vegaro)
* Paywall Components Initial Commit (#4224) via James Borthwick
(@jamesrb1)
* [CustomerCenter] Open App Store when the user wants to update their
app (#4199) via JayShortway (@JayShortway)
* [Customer Center] Shows a warning when the app is not the latest
version (#4193) via JayShortway (@JayShortway)
* Fix integration tests simulator version (#4219) via Cesar de la Vega
(@vegaro)
* Pin swift-docc-plugin to 1.3.0 (#4216) via James Borthwick (@jamesrb1)
nyeu pushed a commit that referenced this pull request Oct 2, 2024
**This is an automatic release.**

### Bugfixes
* Fix `compatibleTopBarTrailing` in MacOS and api tests (#4226) via
Cesar de la Vega (@vegaro)
* [Paywall] Fix restoreStarted not being called on
`presentPaywallIfNeeded` when using `requiredEntitlementIdentifier`
(#4223) via Josh Holtz (@joshdholtz)
* [CustomerCenter] Move sheet and restore alert creation to
`ManageSubscriptionsView` (#4220) via Cesar de la Vega (@vegaro)
* [EXTERNAL] `Custom Entitlements Computation`: fix support display on
debug screen (#4215) by @NachoSoto (#4218) via Toni Rico (@tonidero)
* [Customer Center] Add padding to `No thanks` in promotional offer
screen (#4221) via Cesar de la Vega (@vegaro)
* Fix version number in plist files (#4213) via Cesar de la Vega
(@vegaro)
* fix mac os sandbox check slowness (#3879) via Andy Boedo (@aboedo)
* [Customer Center] Fix `FeedbackSurveyView` not opening (#4208) via
Cesar de la Vega (@vegaro)
* Remove `unneeded_override` disable to fix linter (#4209) via Cesar de
la Vega (@vegaro)
### Dependency Updates
* Bump rexml from 3.3.3 to 3.3.6 in
/Tests/InstallationTests/CocoapodsInstallation (#4210) via
dependabot[bot] (@dependabot[bot])
* Bump rexml from 3.3.3 to 3.3.6 (#4211) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* Update readme wording (#3914) via James Borthwick (@jamesrb1)
* Set a maximum duration for iOS 15 tests (#4229) via Cesar de la Vega
(@vegaro)
* Paywall Components Initial Commit (#4224) via James Borthwick
(@jamesrb1)
* [CustomerCenter] Open App Store when the user wants to update their
app (#4199) via JayShortway (@JayShortway)
* [Customer Center] Shows a warning when the app is not the latest
version (#4193) via JayShortway (@JayShortway)
* Fix integration tests simulator version (#4219) via Cesar de la Vega
(@vegaro)
* Pin swift-docc-plugin to 1.3.0 (#4216) via James Borthwick (@jamesrb1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants