Commit Graph
73 Commits
Author SHA1 Message Date
Antonio Pallares af30b55cae Use RC API key for local development from local.xcconfig (#4795)
* feat: have testing apps take RevenueCat API key and Proxy URL from local.xcconfig file

* fix wording mistakes in `Local.xcconfig.SAMPLE`

* chore: include `ConfigItem.swift` file in `verify_no_included_apikeys` check

* fix more mistakes in comments
2025-02-19 09:48:25 +01:00
Cody Kerns 7bca3bc39c Add convenience method for setting PostHog User ID (#4679) 2025-01-17 09:04:05 -05:00
Toni Rico c24de73950 WebPurchaseRedemption: Rename alreadyRedeemed result to purchaseBelongsToOtherUser (#4542) 2024-12-05 17:44:08 +01:00
98e4a33225 Support anonymous web purchase redemptions (#4439)
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
Co-authored-by: andy boedo <andresboedo@gmail.com>
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
2024-11-25 16:14:32 +01:00
Will Taylor f46bea2565 fix transaction metadata in purchase tester app 2024-11-20 17:51:08 -06:00
Will Taylor 6a363db8df make PurchaseParams & Win-Back APIs public 2024-11-19 13:18:21 -06:00
Mark VillacampaandToni Rico 72b06f6943 Introduce PurchaseParams to allow passing extra configuration info when making a purchase (#4400)
* Introduce PurchaseParams to allow passing extra configuration info when making a purchase

* simplify naming

* fallback to old method when flag is not enabled

* Add $(inherited) to the test targets so they pick up compiler flags from Local.xcconfig

* Include product/package inside PurchaseParams

* fix tests

* add compiler flag check

* update purchase tester

* fix docs

* add tests

* Update Sources/Networking/Operations/PostReceiptDataOperation.swift

Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>

---------

Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
2024-11-06 16:05:37 +07:00
Toni Rico a4e42e6d0a Add tenjinAnalyticsInstallationId setter property (#4437) 2024-11-05 09:39:34 +01:00
JayShortway 40d6a8902e Local.xcconfig is read by PurchaseTester and PaywallsTester (#4367) 2024-10-11 15:52:26 +02:00
Toni RicoandRevenueCat Git Bot fe181bd5e9 Add kochava integration (#4274)
* Reapply "Add `$kochavaDeviceId` attribution convenience method (#4238)" (#4265)

This reverts commit f2ce4416da.

* Add userAgent tracking for attribution networks

* Fix tests

* Add X-Platform-Device header

* Rename user agent to device version

* Use correct attribution method

* [skip ci] Generating new test snapshots (#4278)

* [skip ci] Generating new test snapshots (#4279)

* [skip ci] Generating new test snapshots (#4280)

* [skip ci] Generating new test snapshots (#4281)

* [skip ci] Generating new test snapshots (#4282)

* [skip ci] Generating new test snapshots (#4283)

* Generating new test snapshots (#4284)

* Fix ttests

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2024-09-25 19:59:36 +02:00
Will Taylorandandy boedo 41246f18de Replace withCheckedThrowingContinuation Calls With withUnsafeThrowingContinuation (#4286)
* replace withCheckedThrowingContinuation calls with withUnsafeThrowingContinuation

* replaced instances of withCheckedContinuation -> withUnsafeContinuation

* update the links in comments to point to the issue not the PR

* linting

---------

Co-authored-by: andy boedo <andresboedo@gmail.com>
2024-09-18 11:54:00 -03:00
Toni Rico f2ce4416da Revert "Add $kochavaDeviceId attribution convenience method (#4238)" (#4265)
This reverts commit 871a785d60.
2024-09-11 19:01:55 +02:00
Toni Rico 871a785d60 Add $kochavaDeviceId attribution convenience method (#4238)
### Description
This adds a new API `setKochavaDeviceId` that allows to set the kochava
device ID required for the Kochava integration.

Keeping on hold until backend support is added
2024-09-11 10:06:55 +02:00
Andy Boedo 28b5f2dbf1 More project structure cleanup (#4131)
## More project structure cleanup: 

- Removes redundant workspace and project files for PurchaseTester
- Cleans up bad references
- Cleans up certificates
- Re-does the process to deploy PurchaseTester, since it was designed to
run from the xcworkspace, which doesn't work anymore.
- adds a `dry-run` option to deploying PurchaseTester and adds a job for
it in the all-tests workflow. It tries building it and archiving but
doesn't actually publish to TestFlight. We didn't really have a test for
this, so it's another thing that could have broken in production.
2024-07-31 16:43:15 -03:00
Andy Boedo 51fabaaf25 Clean up XCWorkspace and testing apps (#4111)
## Motivation

Having to remember which Xcode project to open to work on every specific
feature drives me insane.

This just adds the Testing Apps to the main RevenueCat.workspace so we
can launch them from there and I can stop pulling my hair out.

It also removes the old UIKit PurchaseTester since we haven't been using
it for years.

The Backend Integration tests app and the PurchaseTesterSwiftUI app were
using a storekit config file from the old PurchaseTester for some
reason, so I cleaned that up too - added it as a separate file per app.

| Before | After |
| :-: | :-: |
| <img width="312" alt="Screenshot 2024-07-24 at 5 54 55 PM"
src="https://github.com/user-attachments/assets/3afc73b1-3432-4ec0-843c-b9ccfdd371ce">
| <img width="325" alt="image"
src="https://github.com/user-attachments/assets/f5ce7d06-4adc-40d5-a086-73febc0d84cf">
|


# Changes summary: 
- Add all Testing Apps to `RevenueCat.xcworkspace`
- Kill PurchaseTester UIKit
- Move StoreKit config file from PurchaseTester UIKit to
BackendIntegrationTests
- Create new StoreKit Config file for PurchaseTester SwiftUI
- Replace SPM dependency from PurchaseTester -> RevenueCat with a local
dependency
2024-07-29 11:04:47 -03:00
Will Taylor 04ef5b0d1b update purchase tester for 5.0.0 2024-07-02 15:41:35 -05:00
NachoSoto 2bcd0ce328 5.0.0 changes: support SK2 by default 2024-07-01 14:37:21 -05:00
Toni Rico 7d570706fa Diagnostics: Make setting public (#3931)
### Description
This actually enables consumers to use diagnostics by making the setting
public

#### TODO
- [ ] Write docs
- [x] Get #3930 merged
2024-06-03 17:22:49 +02:00
BurdockandJosh Holtz ff68b8a3e4 New syncAttributesAndOfferingsIfNeeded method (#3709)
### Motivation

Adding new method to manually sync attributes and fetch fresh offerings 

### Description

- New `Purchases.shared.syncAttributesAndOfferingsIfNeeded()` method
- Syncs subscriber attributes and then fetches fresh offerings from
network
- This is designed to be a blocking call since developer will want fresh
offerings after syncing subscriber attributes
- The method is rate limited to 5 calls per minute (new `RateLimiter`
class()

---------

Co-authored-by: Josh Holtz <me@joshholtz.com>
2024-02-28 16:13:23 -06:00
61d66bbc32 Add currentOffering(forPlacement: String) to Offerings (#3707)
### Motivation

New function to get `Offering` by a placement identifier

### Description

New `currentOffering(forPlacement: String): Offering?` method on
`Offerings`
- Added demo button for this in purchase tester app

```swift
// Example usage
if let offering = offerings.currentOffering(forPlacement: "onboarding") {
  showPaywall(offering)
}
```

#### Logic flow

- If a placement identifier explicitly exists within the
`placements.offeringIdsByPlacement` dictionary, the method attempts to
fetch the corresponding `Offering` without resorting to a fallback
- Example: when there is a `nil` / null value for a placement, we don't
want to use the fallback
- If the placement identifier does not exist, the method then attempts
to fetch a fallback offering defined by `placements.fallbackOfferingId`

#### New placements object in offerings response

```js
{
    // other offerings stuff
    "placements": {
        "fallback_offering_id": "offering_a", // can be null
        "offering_ids_by_placement": {
            "onboarding_start": null,
            "onboarding_end": "offering_b",
        }
  }
}
```

---------

Co-authored-by: Guido Torres <guido@revenuecat.com>
Co-authored-by: Josh Holtz <me@joshholtz.com>
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2024-02-28 15:11:48 -06:00
Andy Boedo 43652af871 PurchaseTester: improved ReceiptInspector so it accepts receipts with escape sequences (#3554)
Receipts in logs have extra escape sequences now (forward slashes), so
this updates the ReceiptInspector tool to be able to accept them for
easier usage.

It also accepts extra `"` so that if you copied slightly incorrectly it
still works.
2024-01-17 00:01:36 +00:00
Mark VillacampaandNachoSoto 84806ad86e Improve sandbox detector for macOS apps (#3549)
Checking for the presence of `Xcode/DerivedData` in the receipt path was
failing for TestFlight builds or if the .app bundle generated by Xcode
was moved from the folder.

Additionally, checking for `MASReceipt/receipt` seems less robust than
simply using compiler directives.

Instead, for macOS apps, we check the environment embedded in the receipt and alternatively check the signature of the app bundle.

---------

Co-authored-by: NachoSoto <NachoSoto@users.noreply.github.com>
2024-01-09 19:12:47 +01:00
NachoSoto d3866a28e4 visionOS: fix support for Xcode 15.1 beta 3 (#3409)
Apple changed `xrOS` to `visionOS` on the latest beta. Looks like this
was already supported in prior `Xcode 15.1` betas, so this doesn't break
compatibility with them.
2023-11-14 12:51:39 -08:00
235a7dcdc1 StoreKit 2: Optionally send JWS tokens instead of receipts to the backend (#3227)
- Added a new option `usesStoreKit2JWS` under `DangerousSettings`. If
enabled, the SDK will send a JWS token instead of a receipt to the
applicable backend endpoints.
- The option must be used in conjunction with `usesStoreKit2IfAvailable`
configuration option.

### ToDo

- [x] Send JWS token when making a purchase in SK2 mode
- [x] Send JWS token when calculating promo offer eligibility
- [x] Update `syncTransactions` to send the latest transaction JWS.
- [x] Add tests

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
Co-authored-by: Distiller <distiller@static.38.39.183.118.cyberlynk.net>
Co-authored-by: Distiller <distiller@static.198.206.135.125.macminivault.com>
Co-authored-by: Distiller <distiller@static.38.23.39.112.cyberlynk.net>
Co-authored-by: Distiller <distiller@static.38.39.183.58.cyberlynk.net>
Co-authored-by: Distiller <distiller@static.38.39.185.87.cyberlynk.net>
2023-10-16 22:45:29 +02:00
NachoSoto dab5035a19 visionOS: support for Xcode 15 beta 6 (#2989)
### Context:

`#if os(iOS)` no longer evaluates to `true` when compiling for
`visionOS`
Which means we need `|| os(xrOS)`.
But to support older Xcode we need `#if swift(>=5.9) && os(xrOS)`.
But, fun fact, short-circuiting doesn’t work in `Xcode 13`.
And we still need that to run iOS <15 tests (`FB12223404` /
`FB12805891`)

💩 

This works around that by defining our own `VISION_OS` flag.

### Changes:
- Added `VISION_OS` compile time flag to determine SDK
- Replaced `#if os(xrOS)` with `#if VISION_OS`
- Added flag to `Package.swift` (thanks @neonichu for helping with this)
2023-08-09 11:19:40 -07:00
NachoSoto 1cab844f2b Trusted Entitlements: re-enable public API (#2621) 2023-07-11 07:34:39 -07:00
Toni Rico b36adf10fa Remove alpha from purchase tester icon to upload to testflight (#2705)
### Description
While uploading purchase tester to testflight, we were getting these
errors:
```
 [Application Loader Error Output]: ERROR: [ContentDelivery.Uploader] Asset validation failed (90396) Invalid Icon. The watch application 'PurchaseTester.app/Watch/PurchaseTesterWatchOS.app' contains an icon file 'Icon Image-AppIcon-watch-1024x1024@1x.png' with an alpha channel. Icons should not have an alpha channel.
[Application Loader Error Output]: ERROR: [ContentDelivery.Uploader] Asset validation failed (90717) Invalid App Store Icon. The App Store Icon in the asset catalog in 'PurchaseTester.app/Watch/PurchaseTesterWatchOS.app' can't be transparent nor contain an alpha channel.
```

This icon was added in #2701. After trying it manually, removing the
alpha channel seems to have worked in fixing the issue while uploading.
This PR just changes that icon with a version without an alpha channel.
2023-06-26 17:06:28 +02:00
NachoSoto d80bcc99a8 PurchaseTester: fixed watchOS build and ASC deployment (#2701) 2023-06-25 22:49:28 -07:00
NachoSoto 28bf4ceac9 PurchaseTester: fixed release compilation (#2689)
`debugRevenueCatOverlay` is only available on `DEBUG`
2023-06-22 08:54:03 -07:00
NachoSoto 7dc9e90ef3 xrOS: added support to PurchaseTester (#2685)
![image](https://github.com/RevenueCat/purchases-ios/assets/685609/eeb5c7ea-55df-4d11-a06c-c660431c8c08)

![image](https://github.com/RevenueCat/purchases-ios/assets/685609/8435a62c-b14c-4be4-bd08-6d98c690c13d)
2023-06-22 07:49:31 -07:00
NachoSoto 1b2f7f948e PurchaseTester: added ability to display debugRevenueCatOverlay (#2653)
![Screenshot 2023-06-14 at 12 14
08](https://github.com/RevenueCat/purchases-ios/assets/685609/387299bf-afd8-4a09-bece-93a10c9d533c)
2023-06-15 08:12:51 -07:00
NachoSoto 442b683cfe Added .xcprivacy for Xcode 15 (#2619)
Example generated report:

![Screenshot 2023-06-09 at 15 16
11](https://github.com/RevenueCat/purchases-ios/assets/685609/5b4265d5-4102-4938-9efa-1915678fc635)
2023-06-14 12:22:35 -07:00
NachoSoto 6ab11d8a56 PurchaseTester: make CI job always point to current version (#2622) 2023-06-12 07:07:53 -07:00
NachoSoto aca79ae6c7 PurchaseTesterSwiftUI: added ProxyView to iOS (#2531)
Follow up to #2518.

Also fixed the `CustomerInfo` `Picker`, which wasn't working on iOS due
to its design.
2023-05-24 09:49:16 -07:00
NachoSoto 1f9265ac81 PurchaseTesterSwiftUI: added new window on Mac to manage proxy (#2518)
This allows managing the proxy at runtime through the UI:
![Screenshot 2023-05-19 at 2 07 18
PM](https://github.com/RevenueCat/purchases-ios/assets/685609/279828d9-7c7b-4217-b0aa-19a1475e6bf9)

See also https://github.com/RevenueCat/khepri-mitm-proxy/pull/6
2023-05-22 12:04:25 -07:00
NachoSoto 2dcac57529 PurchaseTesterSwiftUI: added visual feedback for purchase success/failure (#2519)
Currently we were only printing that on the console. This will show an
alert after the purchase either fails or succeeds.

![Screenshot 2023-05-19 at 6 06 51
PM](https://github.com/RevenueCat/purchases-ios/assets/685609/d2232119-5321-4139-8657-2a717929edaa)
2023-05-22 11:42:24 -07:00
NachoSoto 24b630adfd PurchaseTesterSwiftUI: fixed macOS UI (#2516) 2023-05-22 07:36:55 -07:00
NachoSoto d2dc5c45dd PurchaseTester: fixed compilation for internal entitlement verification (#2417) 2023-04-19 13:42:56 -07:00
NachoSoto d45e642c47 PurchaseTesterSwiftUI: fixed iOS compilation (#2376) 2023-03-24 15:49:17 -07:00
NachoSoto d9c49690f9 PurchaseTesterSwiftUI improvements (#2345) 2023-03-21 06:35:48 -07:00
NachoSoto 3af5fba011 Made Configuration.EntitlementVerificationMode.enforced unavailable (#2329)
Depends on #2326 and #2328.

This allows us to keep all the code, except users won't be able to
configure the SDK with this option.
Note that `Signing.ResponseVerificationMode.enforced` _is_ available, so
we can still test all that behavior, including from integration tests.
2023-03-13 11:42:52 -07:00
NachoSoto 920f3fe4e3 PurchaseTester: fixed compilation from verification API changes (#2328) 2023-03-07 09:41:36 -08:00
NachoSoto 80e1871866 PurchaseTester: added ability to reload CustomerInfo with a custom CacheFetchPolicy (#2312)
This will help testing cache invalidation in the context of signature
verification.
See
https://linear.app/revenuecat/issue/SDK-2873/invalidate-devicecache-cache-if-entitlement-verification-is-missing

![Screenshot 2023-02-21 at 14 45
17](https://user-images.githubusercontent.com/685609/220475952-e64689e7-ac98-485b-9f13-3e38b9db4e02.png)
2023-02-22 09:10:19 -08:00
NachoSoto 3aaf9de70c PurchaseTester: fixed leak when reconfiguring Purchases (#2311) 2023-02-22 06:55:05 -08:00
NachoSoto 80b29a8ca2 PurchaseTester: added ability to set Configuration.EntitlementVerificationMode (#2290)
<img width="832" alt="Screenshot 2023-02-15 at 16 11 44"
src="https://user-images.githubusercontent.com/685609/219228654-220d7596-aca3-4fa6-8c5c-466173c00865.png">
<img width="916" alt="Screenshot 2023-02-15 at 16 48 00"
src="https://user-images.githubusercontent.com/685609/219229250-47fe810a-7289-4dd8-a1cd-2b6ca49f6438.png">
<img width="372" alt="Screenshot 2023-02-15 at 16 51 41"
src="https://user-images.githubusercontent.com/685609/219229746-91906749-d2df-42b4-8075-e58865061988.png">
2023-02-21 14:40:53 -08:00
Andy Boedo aa8c750a69 PurchaseTester: Add Receipt Inspector UI (#2249)
Adds a new MenuBar UI to the PurchaseTester app on macOS. 

The UI provides a quick utility to parse the local receipt and to check
it against `/verifyReceipt`. This makes it super easy to debug receipts
using PurchaseTester.

<img width="859" alt="image"
src="https://user-images.githubusercontent.com/3922667/214950089-3c6ad4c2-2ae1-4024-83a5-b1490eed9744.png">
2023-02-03 10:58:54 -03:00
NachoSoto 64a9f42a6c PurchaseTester: ignore errors when restoring purchases (#2228)
See #2211.

If `restorePurchases` fails for any reason, we still want to try to load
the local receipt. We're only interested in refreshing the receipt to
load it.
2023-01-18 14:20:53 -08:00
NachoSoto 461d5f2101 PurchaseTester: fixed isPurchasing state when purchasing fails (#2229)
`isPurchasing` was not being set to `false` when a purchase fails, which
lead to the UI being locked.
2023-01-18 13:30:50 -08:00
NachoSoto 4b1c3d1e71 PurchaseTester: added section to visualize AppleReceipt (#2211)
Fixes [CSDK-626].

Depends on #2199, #2200, #2202, #2203, #2204, #2210.

![Simulator Screen Shot - iPhone 14 Pro Max - 2023-01-12 at 09 59
26](https://user-images.githubusercontent.com/685609/212144932-4dd83560-69cd-44c5-9611-100ad35ba525.png)


[CSDK-626]:
https://revenuecats.atlassian.net/browse/CSDK-626?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2023-01-17 13:49:00 -08:00
NachoSoto 81d78089e4 Deploy PurchaseTester for macOS (#2011)
Follow up to #2003. Also submitting `macOS` build for [CSDK-510].

Changed this from `Catalyst` to native `macOS` because of this issue:
https://github.com/fastlane/fastlane/issues/20826


![App_store_512](https://user-images.githubusercontent.com/685609/212436414-1fc826a8-5170-49e5-ab69-aac43ce67466.png)

[CSDK-510]:
https://revenuecats.atlassian.net/browse/CSDK-510?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2023-01-16 18:59:17 -08:00