如何在PKPaymentRequest(ApplePay)中使用applicationData?

时间:2015-12-23 06:28:34

标签: ios applepay application-data

我想在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;

我能够以

的形式访问applicationData
NSError* jsonError;
NSDictionary* dataDict = [NSJSONSerialization JSONObjectWithData:payment.token.paymentData options:kNilOptions error:&jsonError];

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

但数据已编码,我想从applicationData获取@{@"name":@"USER_NAME"}

0 个答案:

没有答案