Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verifySubscriptions method to check all subscriptions in a group at once #333

Merged
merged 14 commits into from
Dec 31, 2017

Conversation

bizz84
Copy link
Owner

@bizz84 bizz84 commented Dec 30, 2017

Related issue: #194

This PR adds a new method:

/**
 *  Verify the validity of a set of subscriptions in a receipt.
 *
 *  This method extracts all transactions mathing the given productIds and sorts them by date in descending order. It then compares the first transaction expiry date against the receipt date, to determine its validity.
 *  - Note: You can use this method to check the validity of (mutually exclusive) subscriptions in a subscription group.
 *  - Remark: The type parameter determines how the expiration dates are calculated for all subscriptions. Make sure all productIds match the specified subscription type to avoid incorrect results.
 *  - Parameter type: .autoRenewable or .nonRenewing.
 *  - Parameter productIds: The product ids of the subscriptions to verify.
 *  - Parameter receipt: The receipt to use for looking up the subscriptions
 *  - Parameter validUntil: Date to check against the expiry date of the subscriptions. This is only used if a date is not found in the receipt.
 *  - return: Either .notPurchased or .purchased / .expired with the expiry date found in the receipt.
 */
public class func verifySubscriptions(ofType type: SubscriptionType = .autoRenewable, productIds: Set<String>, inReceipt receipt: ReceiptInfo, validUntil date: Date = Date()) -> VerifySubscriptionResult

This makes it easy to find the most recent expiration date for a set of subscriptions, and is well suited to check validity within a subscription group.

Example log with output of verifySubscriptions:

verifysubscriptions

  • Add verifySubscriptions method to check all subscriptions in a group at once
  • Rename verifySubscription(type:productId:inReceipt:validUntil:) to verifySubscription(ofType:productId:inReceipt:validUntil:)

@bizz84 bizz84 merged commit 28285c7 into develop Dec 31, 2017
@bizz84 bizz84 deleted the verify-subscriptions branch December 31, 2017 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant