fix: Finding main view controller on iOS
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.
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.
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
Could we please get an update on this merge? @charliecruzan-stripe @jonasbark
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.