gpt4 book ai didi

ios - 将Xcode更新到版本10.4后,Apple Pay无法正常工作

转载 作者:行者123 更新时间:2023-12-01 16:21:51 25 4
gpt4 key购买 nike

Apple Pay在模拟器中运行良好,但是将Xcode升级到10.4后,它停止了工作。

  • 出现Apple Pay弹出窗口。
  • 单击带密码的付款后,它隐藏而不验证付款。
  • 不调用- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion {}方法。

  • 码:
    NSString *merchantIdentifier = [STPPaymentConfiguration sharedConfiguration].appleMerchantIdentifier;
    PKPaymentRequest *paymentRequest = [Stripe paymentRequestWithMerchantIdentifier:merchantIdentifier country:@"US" currency:currencyCode];
    paymentRequest.paymentSummaryItems = @[
    [PKPaymentSummaryItem summaryItemWithLabel:@"Fancy Hat" amount:[NSDecimalNumber decimalNumberWithString:amount]],
    // The final line should represent your company;
    // it'll be prepended with the word "Pay" (i.e. "Pay iHats, Inc $50")
    [PKPaymentSummaryItem summaryItemWithLabel:@"iHats, Inc" amount:[NSDecimalNumber decimalNumberWithString:amount]],
    ];

    if ([Stripe canSubmitPaymentRequest:paymentRequest]) {
    // Setup payment authorization view controller
    PKPaymentAuthorizationViewController *paymentAuthorizationViewController = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
    paymentAuthorizationViewController.delegate = self;

    // Present payment authorization view controller
    FlutterViewController* controller = (FlutterViewController* )[[UIApplication sharedApplication].keyWindow rootViewController];
    [controller presentViewController:paymentAuthorizationViewController animated:YES completion:nil];
    }

    最佳答案

    他们确实更改了签名,因此有一种新方法可以调用iOS11 +,而iOS9和iOS10仍需要旧方法:

     /// for iOS 9 and iOS 10
    func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
    didAuthorizePayment payment: PKPayment,
    completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
    ...
    }

    @available(iOS 11.0, *)
    func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
    didAuthorizePayment payment: PKPayment,
    handler: @escaping (PKPaymentAuthorizationResult) -> Void) {
    ...
    }



    在12.4 Simulator中似乎不起作用。您需要在真实设备上进行测试。装有以前的iOS的模拟器似乎可以运行(iOS10对我有效)。在此问题中讨论了模拟器问题: ApplePay `paymentAuthorizationViewController:didAuthorizePayment:handler:` not called in Xcode Simulator 10.3

    关于ios - 将Xcode更新到版本10.4后,Apple Pay无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57592353/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com