Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for VisionOS #350

Closed
j6alvarez opened this issue Aug 8, 2024 · 2 comments · Fixed by #352
Closed

Support for VisionOS #350

j6alvarez opened this issue Aug 8, 2024 · 2 comments · Fixed by #352

Comments

@j6alvarez
Copy link
Contributor

I have been doing some work with this repo https://github.com/callstack/react-native-visionos

And wanted to contribute sharing what made it work for me following the instructions in this post

Here is the needed code for it to run appleAuth methods for react-native-visionos

Steps:

  1. On RNAppleAuthentication.podspec Add visionos support

s.platforms = { :ios => "9.0", :osx => "10.15", :visionos => "1.0" }

  1. Run bundle install and then bundle exec pod install. Then run build on xcode you'll find some errors

  2. To fix the errors, look for this file RNAppleAuthASAuthorizationDelegates.m
    Add these imports

#import <UIKit/UIKit.h>
#import <AuthenticationServices/AuthenticationServices.h>

Find this if

#if TARGET_OS_OSX
    return [[NSApplication sharedApplication] keyWindow];
#else
    return [[UIApplication sharedApplication] keyWindow];
#endif

And change it for this

#if TARGET_OS_OSX
    return [[NSApplication sharedApplication] keyWindow];
#else
    #if TARGET_OS_VISION
        // visionOS
        UIWindow *window = nil;
        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
        for (UIScene *scene in connectedScenes) {
            if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) {
                UIWindowScene *windowScene = (UIWindowScene *)scene;
                window = windowScene.windows.firstObject;
                break;
            }
        }
        return window;
    #else
        return [[UIApplication sharedApplication] keyWindow];
    #endif
#endif
@mikehardy
Copy link
Collaborator

Happy to take a PR here if you want to make one? Seems very reasonable

@j6alvarez
Copy link
Contributor Author

Done in #352, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants