Skip to content

Commit

Permalink
Fix Null Exceptions on ValidateReceipt iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Sep 28, 2018
1 parent 2b812bf commit 90db719
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 90db719

Please sign in to comment.