App got crashed while using apple pay

      Fatal Exception: NSInvalidArgumentException

0 CoreFoundation 0x8408c __exceptionPreprocess
1 libobjc.A.dylib 0x172e4 objc_exception_throw
2 UIKitCore 0x535ccc -[UIViewController _presentViewController:withAnimationController:completion:]
3 UIKitCore 0x5373cc __63-[UIViewController _presentViewController:animated:completion:]_block_invoke
4 UIKitCore 0x531768 -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
5 UIKitCore 0x5313d4 -[UIViewController _presentViewController:animated:completion:]
6 UIKitCore 0x5311e0 -[UIViewController presentViewController:animated:completion:]
7 Flutter 0x22738 -[FlutterViewController presentViewController:animated:completion:] + 2427 (FlutterViewController.mm:2427)
> 8 square_in_app_payments 0x440c -[FSQIPApplePay requestApplePayNonce:countryCode:currencyCode:summaryLabel:price:paymentType:] + 104 (FSQIPApplePay.m:104)
> 9 square_in_app_payments 0xb15c -[SquareInAppPaymentsFlutterPlugin handleMethodCall:result:] + 100 (SquareInAppPaymentsFlutterPlugin.m:100)
10 Flutter 0x5d41c8 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 322 (FlutterChannels.mm:322)
11 Flutter 0x5eaec ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 110 (ref_ptr.h:110)
12 libdispatch.dylib 0x2370 _dispatch_call_block_and_release
13 libdispatch.dylib 0x40d0 _dispatch_client_callout
14 libdispatch.dylib 0x129e0 _dispatch_main_queue_drain
15 libdispatch.dylib 0x125fc _dispatch_main_queue_callback_4CF
16 CoreFoundation 0x56f64 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
17 CoreFoundation 0x54188 __CFRunLoopRun
18 CoreFoundation 0x535b8 CFRunLoopRunSpecific
19 GraphicsServices 0x11c4 GSEventRunModal
20 UIKitCore 0x3dfb6c -[UIApplication _run]
21 UIKitCore 0x48dfdc UIApplicationMain
22 UIKitCore 0x7bad94 block_destroy_helper.23
23 Runner 0x85b4 main (AppDelegate.swift)
24 ??? 0x1b7f8ed34 (Missing)

Error Stack trace I’m getting in Firebase Crashlytics.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Troubleshoot In-App Payments SDK Problems
Square Developer Documentation
Download, Configure, and Run the Client Sample

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The error stack trace you provided indicates that there’s an issue with presenting a view controller in your application. This could be related to the Square In-App Payments SDK’s Apple Pay functionality, as the stack trace includes a reference to FSQIPApplePay requestApplePayNonce: method.

This error typically occurs when you’re trying to present a view controller from another view controller that is not in the view hierarchy or is in the process of being dismissed.

Ensure that the view controller from which you’re trying to present the Apple Pay view controller is already in the view hierarchy and is not being dismissed. Also, make sure that you’re running this on the main thread, as UI updates should always be done on the main thread.

If you’re still experiencing issues, you may need to debug your application to identify the exact point at which this error is occurring and what the state of your application is at that time.

This answer was reviewed by @Bryan-Square.

The error stack trace you provided indicates that there’s an issue with presenting a view controller in your application. This could be related to the Square In-App Payments SDK’s Apple Pay functionality, as the stack trace includes a reference to FSQIPApplePay requestApplePayNonce: method.

This error typically occurs when you’re trying to present a view controller from another view controller that is not in the view hierarchy or is in the process of being dismissed.

Ensure that the view controller from which you’re trying to present the Apple Pay view controller is already in the view hierarchy and is not being dismissed. Also, make sure that you’re running this on the main thread, as UI updates should always be done on the main thread.

If you’re still experiencing issues, you may need to debug your application to identify the exact point at which this error is occurring and what the state of your application is at that time.

This answer was reviewed by @Bryan-Square.