Commit Graph
11 Commits
Author SHA1 Message Date
NachoSoto 2bcd0ce328 5.0.0 changes: support SK2 by default 2024-07-01 14:37:21 -05:00
Josh HoltzandRevenueCat Git Bot a9737aa7fc Add targeting to PresentedOfferingContext (#3730)
### Motivation

Get more context with targeting information 

### Description

- Parse targeting information into `Offerings`
- Add targeting context into `Offerings.current`
- Add targeting context into `getCurrentOffering(forPlacement: String)`
- Post targeting context in post receipts

---------

Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
2024-02-28 16:10:52 -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
Josh Holtz 67d57a1942 New Package.presentedOfferingContext (#3712)
This was already approved and merged into `5.0-dev` but bringing this
into `4.x` (see #3690)

### Motivation

Allow for storing of other presented offering context on a `Package`

### Description

- Replaced `offeringIdentifier: String` on `Package` with new
`presentedOfferingContext: PresentedOfferingContext`
  - Currently it only has a `offeringIdentifier: String`
- Eventually this will add new optional properties for targeting and
placements
2024-02-28 13:53:42 -06:00
NachoSoto 93b09a27a3 StoreKit 2: added warning to paywall constructors (#3045)
This became a requirement with #3032.
2023-08-22 15:38:30 -07:00
NachoSoto 1350189e90 StoreKit 2: only listen to StoreKit.Transaction.updates when SK2 is enabled (#3032) 2023-08-16 16:04:42 -07:00
Josh HoltzandNachoSoto 31a44f86a6 xrOS: fixed SubscriptionStoreView for visionOS beta 2 (#2884)
### Motivation

visionOS beta 2 had compile errors in `SubscriptionStoreView`

### Description

Replaced `DefaultSubscriptionStoreMarketingContent` with
`AutomaticSubscriptionStoreMarketingContent`

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
2023-07-26 09:07:32 +02:00
NachoSoto 76c440b204 xrOS: fixed compilation by disabling debug overlay (#2681)
We can look into making them work in the future, but for now this helps
compile the SDK for `xrOS`.
2023-06-22 08:42:04 -07:00
NachoSoto 44608c33bb PaywallExtensions: post purchases with Offering identifier (#2645)
### Changes:

- Exposed `internal`-only `Purchases.cachePresentedOfferingIdentifier`
- Changed `SwiftUI` extensions to `static` methods: this is required to
be able to call an instance method on them
- Added integration test to verify this offering identifier is used

Technically this is an API change, but these APIs are implicitly beta
because they're only available in Xcode 15 beta.
2023-06-15 17:16:31 -07:00
NachoSoto 2036f9bb84 PaywallExtensions: fixed compilation (#2613)
Not sure why I didn't notice this when compiling through Xcode, but just
noticed this on CI in #2591.
Fixes:
```
❌ /Users/distiller/purchases-ios/Sources/Support/PaywallExtensions.swift:106:27: 'some' return types are only available in application extensions for iOS 13.0.0 or newer
    private var products: some Sequence<StoreProduct> {
```
2023-06-12 09:36:12 +02:00
NachoSoto 3032007fef Created PaywallExtensions: StoreView and SubscriptionStoreView overloads for Offering (#2593)
### Description
This adds overloads, but there's still a few things pending for the SDK
to fully support these:
- Set `presentedOfferingIdentifier` when displaying StoreKit2 paywalls:
SDK-3176
- Fix `preventPurchasePopupCallFromTriggeringCacheRefresh`: SDK-3172
- Always initialize `StoreKit2TransactionListener` even on SK1 mode:
SDK-3170

### Example:
```swift
struct App: View {

    var offering: Offering

    var body: some View {
        Content()
            .sheet(isPresented: self.$showingSubscriptionSheet) {
                SubscriptionStoreView(offering: self.offering)
            }
    }

}
```
2023-06-09 10:18:41 -07:00