Is there a quick replacement for depreciating `SKPaymentTransaction.transactionReceipt`?

Is there a quick replacement for the unstable SKPaymentTransaction.transactionReceipt?

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];
    }
}
+4
source share
1 answer

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];
    }
}
+5
source

Source: https://habr.com/ru/post/1540713/


All Articles