StoreKit 2 isEligibleForIntroOffer

Hello all, Created and tested successfully auto renewal subscription products in my app. Both products offer 7 days free trial. Once purchased for the first time, isEligibleForIntroOffer value was true and when I tried to subscribe again later, the value is false - everything worked as expected. However, when I reset the eligibility for my sandbox user through the edit subscription screen, I do see that the Free Trial offering becomes available again, as expected, but when I test it in the app, the value for isEligibleForIntroOffer is still false. The value is false for the group (Product.SubscriptionInfo.isEligibleForIntroOffer(for: renewableSubscription.subscriptionGroupID)) and also for the product (renewableSubscription.isEligibleForIntroOffer).

iOS 15.4. Is this a bug? Can I still trust this property value as the only source to check whether the user is eligible for intro in production?

Thanks a lot.

Post not yet marked as solved Up vote post of DudiSG Down vote post of DudiSG
1.8k views
  • also wondering about this - did you find a solution?

Add a Comment

Replies

extension Product { var isEligableForPurchase: Bool { get async { guard type == .autoRenewable, subscription?.introductoryOffer?.type == .introductory else { return true }

        switch await latestTransaction {
        case .verified: return false
        default: return true
        }
    }
}

}

I used this

Better use it:

///Check the subscription to determine whether the user is eligible for an introductory offer.
    public func isEligibleForIntro() -> Bool {        
        let selectedProduct = subscriptions.first(where: { $0.id == selectedProductID })
        return selectedProduct?.subscription?.introductoryOffer?.type == .introductory
    }

Because with https://developer.apple.com/documentation/storekit/product/subscriptioninfo/3803203-iseligibleforintrooffer/

func eligibleForIntro(product: Product) async throws -> Bool {
    guard let renewableSubscription = product.subscription else {
        // No renewable subscription is available for this product.
        return false
    }
    if await renewableSubscription.isEligibleForIntroOffer {
        // The product is eligible for an introductory offer.
        return true
    }
    return false
}

I have a problem with the implementation in View...

Thanx @AaronIntohand