For example: There are two different game characters in a single iPhone device, we call it A and B.
First, app user login as A, he perform an IAP action, the A logout without the purchase completed.
Then, app user login as B, then purchase finish event arrival, this is the problem, how to judge the receipt belongs to A, not B.
I googled, found SKMutablePayment.requestData
may be used for solve this problem, but Apple Document told me this is a reserved property, and must be nil, or else then payment will be reject.
requestData Reserved for future use. (read-only)
@property(nonatomic, copy, readonly) NSData *requestData Discussion The default value is nil. If requestData is not nil, your payment request will be rejected.
Availability Available in iOS 3.0 and later. Declared In SKPayment.h
thanks for everyone's reply
finally, I found SKMutablePayment.applicationUsername can save my private account username, but It only available on iOS7.0.
save:
SKMutablePayment* payment = [SKMutablePayment paymentWithProduct:product];
payment.applicationUsername = @"my_username_1001";
read:
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction* trans in transactions) {
switch (trans.transactionState) {
case SKPaymentTransactionStateFailed:
[[SKPaymentQueue defaultQueue] finishTransaction:trans];
break;
case SKPaymentTransactionStatePurchased:
// got private user account here
NSString* applicationUsername = [[trans payment] applicationUsername];
break;
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStateRestored:
break;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With