Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a fast replacement for deprecate `SKPaymentTransaction.transactionReceipt`?

Is there a fast replacement for deprecate SKPaymentTransaction.transactionReceipt?

The full code:

// saves a record of the transaction by storing the receipt to disk
- (void)recordTransaction:(SKPaymentTransaction *)transaction {
    if ([transaction.payment.productIdentifier isEqualToString:[self getProductId:gFullVersion]]) {
        // save the transaction receipt to disk
        [[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:[self getProductId:gFullVersion]];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}
like image 266
Dmitry Avatar asked Sep 30 '22 19:09

Dmitry


1 Answers

The correct answer should be:

[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]

And the full code:

// saves a record of the transaction by storing the receipt to disk
- (void)recordTransaction:(SKPaymentTransaction *)transaction {
    if ([transaction.payment.productIdentifier isEqualToString:[self getProductId:gFullVersion]]) {
        // save the transaction receipt to disk
        [[NSUserDefaults standardUserDefaults] setValue:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] forKey:[self getProductId:gFullVersion]];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}
like image 74
Dmitry Avatar answered Oct 04 '22 13:10

Dmitry