我想在Apple Pay上设置传递变量,我将NSDictionary
设置为 JSON 数据,如:
PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
[request setApplicationData:[NSJSONSerialization dataWithJSONObject:@{@"name":@"USER_NAME"} options:NSJSONWritingPrettyPrinted error:nil]];
现在在里面:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus status))completion;
我能够以
的形式访问applicationDataNSError* jsonError;
NSDictionary* dataDict = [NSJSONSerialization JSONObjectWithData:payment.token.paymentData options:kNilOptions error:&jsonError];
dataDict [@“header”] [@“applicationData”] 包含应用程序数据
但数据已编码,我想从applicationData获取@{@"name":@"USER_NAME"}
。