我已经阅读了其他可用的答案,但无法理解它。我真的不确定在这种情况下插入密钥的位置
+(BOOL ) getStoreReceipt:(BOOL)sandbox andTrasaction:(SKPaymentTransaction *)tractaion{
NSArray *objects;
NSArray *keys;
NSDictionary *dictionary;
BOOL gotreceipt = false;
@try {
NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL];
if ([[NSFileManager defaultManager] fileExistsAtPath:[receiptUrl path]]) {
NSData *receiptData = [NSData dataWithContentsOfURL:receiptUrl];
NSString *receiptString = [self base64forData:receiptData];
NSLog(@"receiptString Value---->= %@",receiptString);
NSString *encReceipt = [receiptData base64EncodedStringWithOptions:0];
NSLog(@"receiptString Value ======>= %@",encReceipt);
if (receiptString != nil) {
NSString *strSharedSecrect = @"MY_Secrect_Key";
objects = [[NSArray alloc] initWithObjects:receiptString,strSharedSecrect, nil];
keys = [[NSArray alloc] initWithObjects:@"receipt-data",@"password", nil];
dictionary = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
NSString *postData = [self getJsonStringFromDictionary:dictionary];
NSLog(@"postData Value---->= %@",receiptString);
NSString *urlSting = @"https://buy.itunes.apple.com/verifyReceipt";
// if (sandbox) urlSting = @"https://sandbox.itunes.apple.com/verifyReceipt";
dictionary = [self getJsonDictionaryWithPostFromUrlString:urlSting andDataString:postData];
NSLog(@"dictionary Value for receipt---->= %@",dictionary);
if ([dictionary objectForKey:@"status"] != nil) {
if ([[dictionary objectForKey:@"status"] intValue] == 0) {
gotreceipt = true;
}
}
}
}//623065
} @catch (NSException * e) {
gotreceipt = false;
return NO;
NSLog(@"NSException---->= %@",e);
}
if (!gotreceipt) {
NSLog(@"Not gotreceipt---->=");
objects = [[NSArray alloc] initWithObjects:@"-1", nil];
keys = [[NSArray alloc] initWithObjects:@"status", nil];
dictionary = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
return NO;
}else{
BOOL isPurchased = [self PurchasedSubscriptionStatues:dictionary];
return isPurchased;
}
return NO;
}
任何帮助将不胜感激!
答案 0 :(得分:3)
您需要在初始数组地图中添加一个键,同时查看我添加UNIQUE_KEY_NEEDED_HERE_ALSO
的位置。
const recursivelyMapChildren = (node, index) => {
return (
node.children.map((child, i) => {
if (child.text) return child.text
const tag = child.tag
return React.createElement(
tag,
{
key: `${tag}-${index}-${i}`,
className: `text-block-${tag}`,
...child.attributes,
},
recursivelyMapChildren(child, index + 1)
)
})
)
}
const STTextBlock = ({ data }) => {
const textTag = data.content[0].tag
return (
<div className="text-block">
{
data.content.map(textBlock =>
React.createElement(
textTag,
{
key: `UNIQUE_KEY_NEEDED_HERE_ALSO`
className: `${textTag}`,
},
recursivelyMapChildren(textBlock)
)
)
}
<style jsx>{styles}</style>
</div>
)
}