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

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

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 20 '24 13:09 CLAassistant

Very good catch @dluksza, hopefully we can go back to a release version of stripe before we launch the marketplace for OneFootball and 11TeamSports end of next month.

DaveMiller-Stadion avatar Sep 24 '24 08:09 DaveMiller-Stadion

hey @charliecruzan-stripe, what are we missing to get this in? Sorry to bother, but we're happy to make any changes requested and go back to use Stripe from trunk :D

pastre avatar Oct 02 '24 14:10 pastre

Could we please get an update on this merge? @charliecruzan-stripe @jonasbark

DavidMiller-1F avatar Jan 24 '25 13:01 DavidMiller-1F

Should not be needed anymore since we merged https://github.com/janicduplessis/stripe-react-native/blob/9e1a1c9e3ef04351dd0ad6b585e29610b64b7152/ios/StripeSdkImpl.swift#L235, which should handle all cases properly.

janicduplessis avatar Dec 02 '25 04:12 janicduplessis