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

Assert that completeTransactions() was called when the app launches. #337

Merged
merged 2 commits into from
Jan 13, 2018

Conversation

bizz84
Copy link
Owner

@bizz84 bizz84 commented Jan 12, 2018

  • Assert that completeTransactions() was called when the app launches.
  • Update PaymentQueueControllerTests to enqueue purchase calls in the correct order.

Related issue: #287.

Discussion

This PR adds a runtime assertion to check that completeTransactions() was called when the app launches. The assertion is checked when calling purchaseProduct() or restorePurchases(), as these calls are most likely to yield undesired results without a prior call to completeTransactions().

A better way of doing this would be to transform the runtime check into a compile-time constraint.
This could be done by making the CompleteTransactions struct a non-optional parameter passed to the initializer of SwiftyStoreKit. Example:

let swiftyStoreKit = SwiftyStoreKit(CompleteTransactions(atomically: atomically, callback: { purchases in 
   // ...
})
// save swiftyStoreKit and use elsewhere

This would require SwiftyStoreKit to not be a singleton, which would be a big API-breaking change that affects all clients.

For the time being - I will keep this as a runtime check. Hopefully this is enough to prevent problems down the line in testing.

…e app launches.

Update PaymentQueueControllerTests to enqueue purchase calls in the correct order.
@bizz84 bizz84 merged commit a56093c into develop Jan 13, 2018
@bizz84 bizz84 deleted the assert-complete-transactions-called-on-startup branch January 31, 2018 07:40
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