6

我想在 Apple Pay 上设置传递变量,我将其设置NSDictionaryJSON数据,例如:

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;

我能够访问 applicationData 作为

NSError* jsonError;
NSDictionary* dataDict = [NSJSONSerialization JSONObjectWithData:payment.token.paymentData options:kNilOptions error:&jsonError];

dataDict[@"header"][@"applicationData"]包含应用程序数据

但是数据是编码的,我想@{@"name":@"USER_NAME"}从 applicationData 中获取。

4

0 回答 0