stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

fix: Finding main view controller on iOS

Open dluksza opened this issue 1 year ago • 4 comments
trafficstars

In a situation when rootViewController is not set by the application, the main view controller is not found, resulting in error:

Attempt to present <STP_Internal_BottomSheetViewController> on <UIViewController> (from <UIViewController>) whose view is not in the window hierarchy.

which then prevents the Stripe bottom sheet from showing. Blocking the payment flow.

To prevent this, a fallback is added to traverse the windows hierarchy and find the first one that has isKeyWindow set to true.

Testing

  • [x] I tested this manually
  • [ ] I added automated tests

Documentation

Select one:

  • [ ] I have added relevant documentation for my changes.
  • [x] This PR does not result in any developer-facing changes.

dluksza avatar Sep 20 '24 13:09 dluksza