我在 App Store 上发布了一款游戏,在验证收据时,我在以下代码中遇到了几次崩溃:
-(BOOL)isTransactionAndItsReceiptValid:(SKPaymentTransaction *)transaction
{
if (!(transaction && transaction.transactionReceipt && [transaction.transactionReceipt length] > 0))
{
// Transaction is not valid.
return NO;
}
// Pull the purchase-info out of the transaction receipt, decode it, and save it for later so
// it can be cross checked with the verifyReceipt.
NSDictionary *receiptDict = [self dictionaryFromPlistData:transaction.transactionReceipt];
NSString *transactionPurchaseInfo = [receiptDict objectForKey:@"purchase-info"];
...
问题是那receiptDict
不是 a NSDictionary
,所以代码在路上崩溃了。怎么会这样?罐头还有其他形式transaction.transactionReceipt
吗?一个错误?
这种情况很少发生,也许只有 1% 的用户会尝试购买东西?这是人黑的结果吗?
我已经检查以确保它是 and NSDictionary
,但是有一个更深层次的问题,我想找到它。