StoreKIt验证错误:21002 [英] StoreKIt verification error: 21002
问题描述
在一台iPhone 4 / iOS 4的设备,沙箱应用商店验证过程中报告这个错误。
On a iPhone 4/iOS 4 device, sandbox App Store is reporting this error during verification.
21002:在收到数据属性的数据格式不正确
21002: The data in the receipt-data property was malformed.
在一个iPhone 5 / iOS 6的设备,同样的code ++工程(状态== 0,接受返还)没有任何问题。
On a iPhone 5/iOS 6 device, the same code works (status == 0, receipt returned) without any problems.
我已经重新启动设备,确信苹果ID被注销,还送了一个新的测试用户帐户。同样的结果。
I've restarted the device, made sure the Apple ID is logged out, even made a new test user account. Same result.
任何想法?
推荐答案
这个错误意味着你已经创建了发送验证JSON对象的格式不正确。
This Error means the JSON Object that you have created to send for verification is not in correct format.
{
接收数据:(这里收据字节)
}
{ "receipt-data" : "(receipt bytes here)" }
所以我的建议是要调试同在iPhone 4 /的iOS 4.情况下,你是使用JSON框架来创建JSON对象(回执确认)只会与iOS 5.0和放大器工作;以上。
So My suggestion is to Debug the same on iPhone 4/iOS 4. In case, you are Using Json Framework to create JSON object (for receipt validation) it will work only with iOS 5.0 & above.
添加code我实施了几个月,我用来SBJson写ñ解析。
Adding Code I had Implemented a few months I Used SBJson to write N parse.
`
NSString *base64TxReceiptStr=[NSData Base64Encode:transaction.transactionReceipt];
SBJsonWriter *writer = [[SBJsonWriter alloc] init];
NSDictionary *command = [NSDictionary dictionaryWithObjectsAndKeys:
base64TxReceiptStr, @"receipt-data",
nil];
NSString *jsonString = [writer stringWithObject:command];
NSData *requestBody=[jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *txReceiptVerificationRequest=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"]];
[txReceiptVerificationRequest setHTTPBody:requestBody];
[txReceiptVerificationRequest setHTTPMethod:@"POST"];
NSURLResponse *response=nil;
NSError *error=nil;
NSData *responseData=[NSURLConnection sendSynchronousRequest:txReceiptVerificationRequest returningResponse:&response error:&error];
NSString * receivedString=[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *aobject =[parser objectWithString:receivedString];`
这篇关于StoreKIt验证错误:21002的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!