Skip to content

Instantly share code, notes, and snippets.

@alexFaunt
Created June 17, 2018 12:19
Show Gist options
  • Save alexFaunt/5c3e424c6c75a591d42fc6d7e9c803de to your computer and use it in GitHub Desktop.
Save alexFaunt/5c3e424c6c75a591d42fc6d7e9c803de to your computer and use it in GitHub Desktop.
Transaction observer example
switch transaction.transactionState {
case .purchased:
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
let rawReceiptData = Data(contentsOf: appStoreReceiptURL)
let receiptData = rawReceiptData.base64EncodedString(options: ...)
currentUser.processTransaction(receiptData) { isValid in
if isValid {
queue.finishTransaction(transaction);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment