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

[Customer Center] CustomerCenterViewModel checks whether the app is the latest version #4169

Merged
merged 66 commits into from
Aug 16, 2024

Conversation

JayShortway
Copy link
Member

In this PR

  • Logic is added to CustomerCenterViewModel allowing it to check if the app is the latest version.
  • A SemanticVersion struct is added which encapsulates version parsing and comparison logic.
  • The constructors of CustomerCenterViewModel are consolidated somewhat with the use of default arguments, for simplification and to be able to more easily add fake values for the current app version in tests.

Not in this PR

Any UI changes. Will be in a follow-up.

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)
|
Copy link
Member

@aboedo aboedo left a comment

Choose a reason for hiding this comment

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

Looking great!

Comment on lines +160 to +161
]
for (currentVersion, latestVersion, expectedAppIsLatestVersion) in testCases {
Copy link
Member

Choose a reason for hiding this comment

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

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 somehow I often default to parameterized tests. Easy to cover many bases.

Swift Testing is Swift 6 only? We probably can't use that right away after it's released, right?

@aboedo
Copy link
Member

aboedo commented Aug 14, 2024

Swift has a RegexBuilder framework, which would be nice to use here, but is iOS 16+ :/)

lol @jamesrb1 I just read this comment but I had the exact same thought. FWIW a very early early build of RevenueCatUI did use RegexBuilder, but we had to drop it when we extended compatibility to iOS 15

@jamesrb1
Copy link
Contributor

lol @jamesrb1 I just read this comment but I had the exact same thought. FWIW a very early early build of RevenueCatUI did use RegexBuilder, but we had to drop it when we extended compatibility to iOS 15

One day... but probably many days from now...

@JayShortway
Copy link
Member Author

@RCGitBot please test

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 great!

@JayShortway JayShortway enabled auto-merge (squash) August 16, 2024 09:59
@JayShortway JayShortway merged commit 081b653 into main Aug 16, 2024
5 checks passed
@JayShortway JayShortway deleted the check-latest-version branch August 16, 2024 10:02
@JayShortway JayShortway added refactor and removed pr:feat A new feature labels Aug 16, 2024
@JayShortway
Copy link
Member Author

Changed the label, because I'd imagine we don't want this under "New Features" in the changelog until it's properly released.

joshdholtz added a commit that referenced this pull request Aug 22, 2024
**This is an automatic release.**

### New Features
* Price rounding logic (#4132) via James Borthwick (@jamesrb1)
### Bugfixes
* [Customer Center] Migrate to List style (#4190) via Cody Kerns
(@codykerns)
* [Paywalls] Improve locale consistency (#4158) via Josh Holtz
(@joshdholtz)
* Set Paywalls Tester deployment target to iOS 15 (#4196) via James
Borthwick (@jamesrb1)
* [Customer Center] Hide Contact Support button if URL can't be created
(#4192) via Cesar de la Vega (@vegaro)
* Fix the setting for SKIP_INSTALL in Xcode project (#4195) via Andy
Boedo (@aboedo)
* [Customer Center] Improving customer center buttons (#4165) via Cody
Kerns (@codykerns)
* Revert workaround for iOS 18 beta 5 SwiftUI crash (#4173) via Mark
Villacampa (@MarkVillacampa)
* [Paywalls] Make iOS version calculation lazy (#4163) via Mark
Villacampa (@MarkVillacampa)
* [Paywalls] Observe `PurchaseHandler` when owned externally (#4097) via
James Borthwick (@jamesrb1)
### Other Changes
* [Customer Center] Clean up colors in WrongPlatformView and
NoSubscriptionsView (#4204) via Cesar de la Vega (@vegaro)
* Fix failing `all-tests` and retry more flaky tests (#4188) via Josh
Holtz (@joshdholtz)
* Compatibility content unavailable improvements (#4197) via James
Borthwick (@jamesrb1)
* Create lane to enable customer center (#4191) via Cesar de la Vega
(@vegaro)
* XCFramework artifacts in CircleCI (#4189) via Andy Boedo (@aboedo)
* [Customer Center] CustomerCenterViewModel checks whether the app is
the latest version (#4169) via JayShortway (@JayShortway)
* export RevenueCatUI xcframework (#4172) via Andy Boedo (@aboedo)
* Corrects references from ManageSubscriptionsButtonStyle to
ButtonsStyle. (#4186) via JayShortway (@JayShortway)
* Speed up carthage installation tests (#4184) via Andy Boedo (@aboedo)
* Customer center improvements (#4166) via James Borthwick (@jamesrb1)
* replace `color(from colorInformation:)` global with extension (#4183)
via Andy Boedo (@aboedo)
* Fix tests in main (#4174) via Andy Boedo (@aboedo)
* Enable customer center tests (#4171) via James Borthwick (@jamesrb1)
* [Customer Center] Initial implementation (#3967) via Cesar de la Vega
(@vegaro)

---------

Co-authored-by: Josh Holtz <me@joshholtz.com>
nyeu pushed a commit that referenced this pull request Oct 2, 2024
nyeu pushed a commit that referenced this pull request Oct 2, 2024
**This is an automatic release.**

### New Features
* Price rounding logic (#4132) via James Borthwick (@jamesrb1)
### Bugfixes
* [Customer Center] Migrate to List style (#4190) via Cody Kerns
(@codykerns)
* [Paywalls] Improve locale consistency (#4158) via Josh Holtz
(@joshdholtz)
* Set Paywalls Tester deployment target to iOS 15 (#4196) via James
Borthwick (@jamesrb1)
* [Customer Center] Hide Contact Support button if URL can't be created
(#4192) via Cesar de la Vega (@vegaro)
* Fix the setting for SKIP_INSTALL in Xcode project (#4195) via Andy
Boedo (@aboedo)
* [Customer Center] Improving customer center buttons (#4165) via Cody
Kerns (@codykerns)
* Revert workaround for iOS 18 beta 5 SwiftUI crash (#4173) via Mark
Villacampa (@MarkVillacampa)
* [Paywalls] Make iOS version calculation lazy (#4163) via Mark
Villacampa (@MarkVillacampa)
* [Paywalls] Observe `PurchaseHandler` when owned externally (#4097) via
James Borthwick (@jamesrb1)
### Other Changes
* [Customer Center] Clean up colors in WrongPlatformView and
NoSubscriptionsView (#4204) via Cesar de la Vega (@vegaro)
* Fix failing `all-tests` and retry more flaky tests (#4188) via Josh
Holtz (@joshdholtz)
* Compatibility content unavailable improvements (#4197) via James
Borthwick (@jamesrb1)
* Create lane to enable customer center (#4191) via Cesar de la Vega
(@vegaro)
* XCFramework artifacts in CircleCI (#4189) via Andy Boedo (@aboedo)
* [Customer Center] CustomerCenterViewModel checks whether the app is
the latest version (#4169) via JayShortway (@JayShortway)
* export RevenueCatUI xcframework (#4172) via Andy Boedo (@aboedo)
* Corrects references from ManageSubscriptionsButtonStyle to
ButtonsStyle. (#4186) via JayShortway (@JayShortway)
* Speed up carthage installation tests (#4184) via Andy Boedo (@aboedo)
* Customer center improvements (#4166) via James Borthwick (@jamesrb1)
* replace `color(from colorInformation:)` global with extension (#4183)
via Andy Boedo (@aboedo)
* Fix tests in main (#4174) via Andy Boedo (@aboedo)
* Enable customer center tests (#4171) via James Borthwick (@jamesrb1)
* [Customer Center] Initial implementation (#3967) via Cesar de la Vega
(@vegaro)

---------

Co-authored-by: Josh Holtz <me@joshholtz.com>
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