我想在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"]包含应用程序数据
但数据是编码的,我想@{@"name":@"USER_NAME"}
从applicationData 获得.