Search code examples
iosbraintreeapplepay

Braintree Drop In Apple Pay crashing


Presenting PKPaymentAuthorizationViewController always results in a total crash with pointing to my AppDelegate: Thread 1: signal SIGABRT

let vc = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) as PKPaymentAuthorizationViewController?

if vc != nil{

    vc!.delegate = self

    self.present(vc!, animated: true, completion: nil)

}else{
    print("error")
}

libc++abi.dylib: terminating with uncaught exception of type NSException

btw.: I am checking .canMakePayments() if it is available first.

The exception message is

Supported orientations has no common orientation with the application, and [PKPaymentAuthorizationViewController shouldAutorotate] is returning YES


Solution

  • The PKPaymentAuthorizationViewController is presented in portrait orientation so that FaceID functions correctly.

    You are getting an exception as you have only landscape options selected under 'Device Orientation' in your project. You need to add portrait to this list.

    enter image description here

    You can limit the rest of your view controllers to landscape orientation if that is what you want.