subscriptionPromotionalOffer(offer:compactJWS:)
Selects a promotional offer to apply to a purchase a customer makes from a subscription store view.
Declaration
nonisolated func subscriptionPromotionalOffer(offer: @escaping (Product, Product.SubscriptionInfo) -> Product.SubscriptionOffer?, compactJWS: @escaping (Product, Product.SubscriptionInfo, Product.SubscriptionOffer) async throws -> String) -> some View
Parameters
- offer:
The system calls this function before drawing the given subscription product on the subscription store view. Return the promotional offer to apply to the product, if any, to have system-provided UI reflect the discounted terms under the selected offer.
- compactJWS:
The system calls this function before processing a purchase, with the product to be purchased provided as a parameter, along with the selected subscription offer to be applied to the purchase. Return a compact JWS signature you generate on your server that validates the selected offer. Errors thrown from this closure will be surfaced via the Oninapppurchasecompletion(perform:) modifier. For information about generating the JWS signature, see Generating Jws To Sign App Store Requests..
Discussion
Subscription stores within this view uses the specified subscription offer to configure the appearance of the subscription plans displayed, when you use a system-provided SubscriptionStoreControlStyle to style the in-app subscription store. Standard ProductViewStyle instances don’t show introductory or promotional offers in UI. Use the SubscriptionStoreView instead to show these offers in the UI.
If the signature passes validation for the offer you select, the system applies the offer to the purchase. If the signature fails validation for the offer you select, the purchase fails with Product.PurchaseError.invalidOfferSignature.
Promotional offers you select in this modifier overwrite any offers you specified in ancestor views.