Commit Graph
47 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
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
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
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
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
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
NachoSoto 1cab844f2b Trusted Entitlements: re-enable public API (#2621) 2023-07-11 07:34:39 -07: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 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 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
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 9fa5986394 PurchaseTester: small refactor to simplify Date formatting (#2210)
For [CSDK-626].

[CSDK-626]:
https://revenuecats.atlassian.net/browse/CSDK-626?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2023-01-12 11:34:21 -08:00
NachoSoto e93a23037b Purchase Tester: display specific IntroEligibilityStatus (#2184)
Before this change we were displaying `"no"` instead of
`noIntroOfferExists`, which was confusing.


![IMG_6664](https://user-images.githubusercontent.com/685609/208978733-25353b1b-052d-4399-ae49-83f923ec511b.png)
2022-12-22 08:44:40 -08:00
NachoSoto 223b525752 Purchase Tester: fixed SubscriptionPeriod (#2185)
This was probably done before we exposed this as part of `StoreProduct`.
With SK2 enabled, no period was being displayed.
2022-12-22 08:44:00 -08:00
NachoSoto f9793d72d3 Purchase Tester: added ability to purchase products directly with StoreKit (#2172)
This will help test observer mode, mimicking how an app might use
`RevenueCat` with observer mode.

When that setting is enabled, 2 new buttons will appear:
![Simulator Screen Shot - iPhone 14 Pro Max - 2022-12-20 at 08 58
07](https://user-images.githubusercontent.com/685609/208723050-56644a9a-d78f-4788-bda1-b64bdc400b40.png)

The implementation isn't the most maintainable, but we don't really need
it to be. I favored simplicity instead of over-complicating the
implementation. It's not meant to be a canonical example of the correct
way to purchase with StoreKit, just a quick way of testing this
behavior.
2022-12-21 08:29:47 -08:00
NachoSoto dd2e161199 Purchase Tester: added button to clear messages on logger view (#2179)
See #2012.
This is useful when debugging some feature. You can now clear the logs
before performing whatever action you need to test, and have a cleaner
output with only the logs from that point.

![Screenshot 2022-12-20 at 13 40
18](https://user-images.githubusercontent.com/685609/208772324-7433194b-2274-4d18-a64b-ad42fd30900e.png)
2022-12-21 08:19:09 -08:00
NachoSoto a9aba75345 PurchaseTester: fixed macOS support (#2175) 2022-12-21 08:02:42 -08:00
NachoSoto 432b704dc7 Purchase Tester: added companion watchOS app (#2140)
I added this in order to debug #2132.

### Changes:
- Extracted `Core` framework to be used by both apps
- Added new `watchOS` target
- Changed `fastlane match` to also create profiles for this new target
- Added a simple view in the watch app that displays a text if an
entitlement is active, or a `restore` purchases button otherwise

This is just a starting point, we can add more to it in the future.

#### Note:
_Unfortunately I haven't been able to test this because of an Apple bug
(`FB11873951`):_


![incoming-722CC7FA-D970-4E23-AB88-50167248D98D](https://user-images.githubusercontent.com/685609/207672762-23abe3e7-6052-4b16-bdf2-7b1e502ffd81.PNG)
2022-12-21 07:31:58 -08:00
NachoSoto 97c337f48d Purchase Tester: fixed error alerts (#2169) 2022-12-20 07:27:27 -08:00
NachoSoto d8457c5e31 PurchaseTesterSwiftUI: added observer mode setting (#2052)
Can be useful when debugging observer mode.

<img width="734" alt="Screenshot 2022-11-14 at 09 48 21"
src="https://user-images.githubusercontent.com/685609/201731589-e412865d-d6e9-4032-afae-1ae191196c51.png">
2022-11-23 11:22:45 -06:00
NachoSoto 37591adb62 PurchaseTesterSwiftUI: replaced Purchases dependency with SPM (#2027) 2022-11-08 04:37:27 -08:00
NachoSoto 1d008932dc PurchaseTesterSwiftUI: added "logs" screen (#2012)
Since `PurchaseTester` will be used through `TestFlight`, I made it
possible to view console logs directly from the app:

## iOS


![IMG_5974](https://user-images.githubusercontent.com/685609/198735797-c5f6b4ed-edfb-42dc-a470-452201a03645.PNG)

## Catalyst

![Screenshot 2022-10-28 at 14 29
32](https://user-images.githubusercontent.com/685609/198735975-34d34b8e-491e-4b8d-8df9-eb2e58ff94c7.png)
2022-11-03 14:47:01 -07:00
NachoSoto 2773783274 PurchaseTesterSwiftUI: allow configuring API key at runtime (#1999)
Fixes [CSDK-456].

### Configuration screen:
![Simulator Screen Shot - iPhone 13 Pro Max - 2022-10-25 at 15 02
26](https://user-images.githubusercontent.com/685609/197890837-3160d9cd-72e0-45d7-8e9e-f248b0dd93c5.png)

### Displaying errors:
_Note that if you enter an invalid API key and there's a credentials
issue, you can tap on "reconfigure" to start over:

![Simulator Screen Shot - iPhone 13 Pro - 2022-10-26 at 13 35
42](https://user-images.githubusercontent.com/685609/198134117-d80f7c28-922b-4c48-be83-9b8ec03de299.png)

[CSDK-456]:
https://revenuecats.atlassian.net/browse/CSDK-456?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-11-03 14:44:42 -07:00
NachoSoto e3b650e306 PurchaseTesterSwiftUI: combined targets into one multi-platform and fixed macOS (#1996)
Working towards [CSDK-456].

[CSDK-456]:
https://revenuecats.atlassian.net/browse/CSDK-456?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-10-28 12:17:49 -07:00
NachoSoto d14611240a PurchaseTesterSwiftUI: fixed warnings and simplified code using async methods (#1985)
Fixing warnings before working on a few improvements
2022-10-26 11:25:46 -07:00
Josh Holtz 971b596727 New SwiftUI Purchase Tester example (#1722)
* Initial commit of new SwiftUI Purchase Tester

* Mover to Test/TestingApps/PurchaseTesterSwiftUI and updated deprecated attribution stuff

* Undoing things here because whoops

* Updates from PR
2022-06-24 09:33:13 -05:00