Commit Graph
23 Commits
Author SHA1 Message Date
Facundo Menzella 6b5c430082 chore: Enable force_unwrapping for SwiftLint (#4820)
* enable force_unwrapping

* avoid force unwrap

* fixed all errors

* remove extra disable
2025-02-26 12:40:49 +01:00
James Borthwick 22ff468e88 Support to round+truncate prices displayed on paywalls for backend-specified countries (#4132)
## Rounds prices for certain locales.

The server now returns a list of storefront country codes where paywalls
should not display cents. This part of paywall data, in
`zero_decimal_place_countries`.

Prices are only truncated if the price ends in .00.
2024-08-16 11:00:38 -05:00
Josh Holtz 363bb0ce09 Added new paywall template to support multiple tiered subscriptions (#4022)
### Motivation

Template 5 but with multiple tiers 😊

### Description

Enabling Template 7 by changing `7_disabled` to `7`

- Changed a `header.jpg` to `header.heic` to try and fix issue with
weirdly failing snapshot UI test
- Changed visibility on `TestData` from `public` to `internal`
- Hides tier selector if only one tier
- Changed `color_overrides_by_tier` to `colors_by_tier` and
`image_overrides_by_tier` to `images_by_tier`
- The original implementation was going to default to existing color and
images configurations and then override by tier
- However, this turned out to be harder to implement on the
configuration side
- `Colors` got four new optional values
  - `tier_control_background`
  - `tier_control_foreground`
  - `tier_control_selected_background`
  - `tier_control_selected_foreground`

### Demo

#### Full Screen


https://github.com/RevenueCat/purchases-ios/assets/401294/e5317a53-428c-415e-a1a1-b4231d32a776

### Footer


https://github.com/RevenueCat/purchases-ios/assets/401294/8905b55e-0fa2-49f0-aa1c-d4c1e694fb5b

### Footer Condensed


https://github.com/RevenueCat/purchases-ios/assets/401294/311d78fb-bdeb-43cd-b601-9c60a8a54b6f
2024-07-17 07:04:42 -05:00
NachoSoto e5b5bb0a4d Paywalls: add 4 new variables (#3629)
### Added:
- `price_per_period_full`
- `total_price_and_per_month_full`
- `sub_period_length`
- `sub_period_abbreviated`
2024-02-05 09:18:34 -08:00
Andy BoedoandNachoSoto 56f7178145 Paywalls: fix empty description when using custom package type and {{ sub_period }} (#3495)
If you select a custom package type and set Offer Period, the paywall
would have an empty entry for that package.


<img width="802" alt="image"
src="https://github.com/RevenueCat/purchases-ios/assets/3922667/fa50e15b-b122-4caa-816e-3250f10d5d89">

| Before | After |
| :-: | :-: |
| ![IMG_908CED5B663B-1
(1)](https://github.com/RevenueCat/purchases-ios/assets/3922667/2519c74e-c0d2-44c1-a126-64bd78808384)
|
![IMG_B1CED574DF20-1](https://github.com/RevenueCat/purchases-ios/assets/3922667/1eaf17d6-75fd-4e20-86cf-ef93de2d74d3)
|

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
2023-12-08 07:17:49 +08:00
NachoSotoandAndy Boedo af08736775 RevenueCatUI: added support to other deployment targets (#3392)
Follow up to #3378.

This allows us to link both `RevenueCat` and `RevenueCatUI` from
`PurchasesHybridCommon` supporting the same platforms.
The actual types might not be available in some platforms / versions,
but we can detect that at compile time.

See
https://app.circleci.com/pipelines/github/RevenueCat/purchases-hybrid-common/2564/workflows/ea6a4e24-e1eb-4c7a-a930-173945732999/jobs/10352

---------

Co-authored-by: Andy Boedo <andresboedo@gmail.com>
2023-11-08 07:35:19 -08:00
NachoSoto 91f780b982 Paywalls: new {{ sub_price_per_week }} variable (#3355) 2023-11-01 08:34:00 -07:00
NachoSoto 789d8f34a7 Paywalls: new {{ sub_duration_in_months }} variable (#3173) 2023-09-14 18:28:11 -07:00
NachoSoto f617fbb2cd Paywalls: new {{ sub_relative_discount }} variable (#3131) 2023-09-14 18:28:11 -07:00
NachoSoto 2103b04762 Paywalls: added MIT license to all headers (#3084)
`Xcode` doesn't allow customizing the header (looks like maybe it worked
at some point but not anymore:
https://stackoverflow.com/questions/67614785/changing-the-default-header-comment-license-in-swift-package).

At least this adds the license to all the initial files in the package.
2023-09-14 18:28:11 -07:00
NachoSoto 8c587bcc65 Paywalls: validate PaywallData to ensure displayed data is always correct (#3019)
See
https://docs.google.com/document/d/1oLZR77apAjZf04hDzlrJpPaFV0xhuQ1-hApsNBohhfA/edit

This simplifies `PaywallView`: the validated `PaywallData` is what's
always displayed, and a `DebugErrorView` containing an error description
will potentially explain why a default paywall is being displayed.

### Validations:

- [x] `Offering` contains a `PaywallData`
- [x] `PaywallLocalizedConfiguration` contains no unrecognized variables
- [x] `PaywallIcon`s are all recognized
- [x] `PaywallTemplate` is recognized
2023-09-14 18:28:11 -07:00
NachoSoto b1860eb391 Paywalls: improved variable warning (#2984) 2023-09-14 18:28:11 -07:00
NachoSoto df7bd8b33f Paywalls: updated variable names (#2970)
These match the new agreed upon variables.

- Improved the localized unit abbreviations
- Refactored `VariableDataProvider` so all the logic is now in `Package`
- Added new tests for `Package` variables
2023-09-14 18:28:11 -07:00
NachoSoto 534a556e62 Paywalls: initial iOS 15 support (#2933)
`PaywallView` and `PaywallViewController` (along with the extensions)
still require iOS 16, but this paves the way to support iOS 15 down the
road if we need to.

### Main Changes:

- Changed all `@available` annotations
- Added CI tests
- Replaced `ViewThatFits` with the "biggest" version
- Because of that, `scrollableIfNeeded` is always scrollable
- Double `Regex` implementation (keeping the modern one), so once we
drop support for iOS 15 we can just keep the modern one.

### TODO: 
- [x] Add snapshots
- [x] Test paywalls
- [x] Updated APITester to verify this
2023-09-14 18:28:11 -07:00
NachoSoto e78c8782d0 Paywalls: added support for custom and lifetime products (#2941)
The main change is that `VariableHandler` no longer cashes when trying
to determine price per month for non-subscriptions. I added a test to
cover this behavior.
2023-09-14 18:28:11 -07:00
NachoSoto 999cbea29c Paywalls: new subscription_duration variable (#2942)
This will be used by template 4, but also useful in others.
2023-09-14 18:28:11 -07:00
NachoSoto 005a9b9cf8 Paywalls: avoid recomputing variable Regex (#2944)
See #2811.
It's unclear from the docs whether this is a performance optimization,
but at least it's a nice refactor.
2023-09-14 18:28:11 -07:00
NachoSoto 3dffee3d1e Paywalls: added a few more logs (#2927)
Also improved logging by using `verboseLogHandler` and a new `Strings`
enum.
2023-09-14 18:28:11 -07:00
NachoSoto 82a96c1f82 Paywalls: improved default paywall configuration (#2926)
This could still use more polish, but some basic fixes:
- Fixed colors
- Added application name as a title
- Using `total_price_and_per_month` instead of `price_per_month` so it
also works with monthly subscriptions
- Added snapshot test for its dark mode version
2023-09-14 18:28:11 -07:00
NachoSoto dc3be2215e Paywalls: fixed {{ total_price_and_per_month }} (#2881)
We were relying on both the price and price per month to be formatted
the same way. When debugging in the simulator, the actual region doesn't
change, so StoreKit's internal price formatter doesn't pick it up.
To make this more resilient, this now checks whether it's a monthly
subscription instead of comparing strings.

This is an example where `Locale.current` is only overriden partially
and the logic breaks:

![image](https://github.com/RevenueCat/purchases-ios/assets/685609/76eabfdb-ea16-4d67-b7b3-411a3c4393a5)
2023-09-14 18:28:11 -07:00
NachoSoto b1af8eb776 Paywalls: new {{ period }} variable (#2876)
This represents the localized `PackageType`.
2023-09-14 18:28:11 -07:00
NachoSoto 3f18b6fcef Paywalls: added new total_price_and_per_month variable (#2845)
This also expands `Localization` support to be able to format this in
any language.
2023-09-14 18:28:11 -07:00
NachoSoto 947917f9ad Paywalls: extracted configuration processing into a new TemplateViewConfiguration (#2830)
### Changes:
- Created `TemplateViewConfiguration` to encapsulate all processed
configuration for a paywall
- Created `TemplateViewConfiguration.PackageSetting` and
`TemplateViewConfiguration.PackageConfiguration` to represent paywalls
that support 1 or N packages
- Taken all common logic out of `Example1Template`
- Added new `PaywallViewMode` for upcoming "ramps" views
2023-09-14 18:28:11 -07:00