Skip to content

Commit

Permalink
Merge pull request #186 from jamesmontemagno/bug/issue-170
Browse files Browse the repository at this point in the history
Fix Null Exceptions on ValidateReceipt iOS
  • Loading branch information
jamesmontemagno committed Sep 28, 2018
2 parents 2b812bf + 90db719 commit 08571bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
Expand Up @@ -217,8 +217,11 @@ Task<bool> ValidateReceipt(IInAppBillingVerifyPurchase verifyPurchase, string pr

// Get the receipt data for (server-side) validation.
// See: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Introduction.html#//apple_ref/doc/uid/TP40010573
var receiptUrl = NSData.FromUrl(NSBundle.MainBundle.AppStoreReceiptUrl);
var receipt = receiptUrl.GetBase64EncodedString(NSDataBase64EncodingOptions.None);
NSData receiptUrl = null;
if(NSBundle.MainBundle.AppStoreReceiptUrl != null)
receiptUrl = NSData.FromUrl(NSBundle.MainBundle.AppStoreReceiptUrl);

var receipt = receiptUrl?.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

return verifyPurchase.VerifyPurchase(receipt, string.Empty, productId, transactionId);
}
Expand Down

0 comments on commit 08571bc

Please sign in to comment.