[英]Unable to access Phone no, First-Last Name, Street from PKContact inside PKPaymentAuthorizationViewController delegate method didSelectShippingContact
[英]PKPaymentAuthorizationViewController not calling delegate
我已经使用有效的 PKPaymentRequest 设置了一个 PKPaymentAuthorizationViewController,并使用有效的测试卡和送货地址从沙箱登录了一个帐户。 我已将地区更改为美国,但没有任何变化。 该应用程序具有所有有效的证书和权利。
func getApplePayController(request: PKPaymentRequest) -> PKPaymentAuthorizationViewController? {
guard let vc = PKPaymentAuthorizationViewController(paymentRequest: request) else {
return nil
}
//Set ourselves as delegate to get callbacks on the transaction status
vc.delegate = self
//we keep a weak reference to the controller to be able to dismiss it if necessary
self.applePayViewController = vc//This is weak
return vc
}
并介绍:
//Show Apple Pay screen with configured PKPaymentRequest object
guard let vc = getApplePayController(request: paymentRequest) else {
dLog("Error instantiating Apple Pay screen")
handleEventType(.status(.failed))
return
}
assert(delegate != nil)
assert(applePay.didAuthorize == false)
assert(vc.delegate != nil)
//disable swipe to dismiss
if #available(iOS 13.0, *) {
vc.isModalInPresentation = true
}
if var topController = UIApplication.shared.keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
// topController should now be your topmost view controller
topController.present(vc, animated: true, completion: nil)
}
屏幕出现,如果我点击取消,一切都会冻结。 如果我点击背景,屏幕会自动关闭,但视图的其余部分不是交互式的(PKPaymentAuthorizationViewController 没有关闭,但它的 ui 被隐藏)。 如果我点击“支付”,它会要求输入密码,但它会卡住处理。 在任何一种情况下都不会调用委托。
我的实现:
public func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {
print("Dismiss")
}
public func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
didAuthorizePayment payment: PKPayment,
completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
completion(.success)
return;
}
@available(iOS 11.0, *)
public func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
didAuthorizePayment payment: PKPayment,
handler: @escaping (PKPaymentAuthorizationResult) -> Void) {
handler(PKPaymentAuthorizationResult(status: .success, errors: nil))
return;
}
无论我做什么,都不会调用这三种方法中的任何一种。 我已经检查过并且委托设置正确。
任何的想法?
我现在也实现了 PKPaymentAuthorizationControllerDelegate 即使我没有使用它并且它可以工作......
public func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) {
return
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.