FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
2.01k stars 438 forks source link

fix: iOS crash when scenes are enabled #995

Open kononenkoAnton opened 3 months ago

kononenkoAnton commented 3 months ago

Fixes #...

Description

iOS crashes when presenting a view controller while the application is using scenes: https://developer.apple.com/documentation/uikit/app_and_environment/scenes/ The issue occurs because each scene has its own window.

UIViewController *presentingViewController = appDelegate.window.rootViewController.view.window ? appDelegate.window.rootViewController : appDelegate.window.rootViewController.presentedViewController;

presentingViewController returns nil IMG_7244

Steps to verify

  1. Prepare an application where scenes are enabled: https://developer.apple.com/documentation/uikit/app_and_environment/scenes/specifying_the_scenes_your_app_supports#3262273
  2. On the RN side, call authorize from "react-native-app-auth"
changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 773b378a0bfab4c086821e4169a1da1cfb98bc50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------------- | ----- | | react-native-app-auth | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-app-auth ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2024 6:26pm
zibs commented 2 months ago

Hey @kononenkoAnton thanks for the PR!

This does seem like it works, but do you think you could provide us with a really stripped down minimal example repo of a RN app that supports scenes as you mentioned.

I haven't used this before and have something clunky set up locally, but would love a reproducible app we could look at/test against in the future.

Let me know, thanks!

zibs commented 2 months ago

Hey @kononenkoAnton - just wanted to give you a friendly ping to see if you'd be up for providing a repro here!

zibs commented 2 months ago

Hey @kononenkoAnton I've been running the https://github.com/microsoft/react-native-test-app without your fix, and it seems like it works correctly still. The RNTA (react-native-test-app) has multiple window support enabled by default and seemed like a good place to test this.

I'm wondering if this might be an issue with your set up instead of an issue with the library.

Let me know if you think you can provide a stripped down example of your implementation, thanks!