是否有快速替代弃用`SKPaymentTransaction.transactionReceipt`?

时间:2014-05-15 13:41:46

标签: ios ios7 in-app-purchase deprecated

是否可以快速替换弃用SKPaymentTransaction.transactionReceipt?

完整代码:

// 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];
    }
}

1 个答案:

答案 0 :(得分:5)

正确的答案应该是:

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

完整代码:

// 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];
    }
}