Skip to content

Commit

Permalink
Support for VisionOS
Browse files Browse the repository at this point in the history
  • Loading branch information
j6alvarez committed Sep 13, 2024
1 parent 8702b44 commit d33fc1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RNAppleAuthentication.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.authors = "Invertase Limited"
s.source = { :git => "https://github.com/invertase/react-native-apple-authentication.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/invertaseio'
s.platforms = { :ios => "9.0", :osx => "10.15" }
s.platforms = { :ios => "9.0", :osx => "10.15", :visionos => "1.0" }
s.source_files = 'ios/**/*.{h,m}'
s.dependency 'React-Core'
s.static_framework = true
Expand Down
18 changes: 17 additions & 1 deletion ios/RNAppleAuthentication/RNAppleAuthASAuthorizationDelegates.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/

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


@implementation RNAppleAuthASAuthorizationDelegates
Expand All @@ -34,7 +36,21 @@ - (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthoriz
#if TARGET_OS_OSX
return [[NSApplication sharedApplication] keyWindow];
#else
return [[UIApplication sharedApplication] keyWindow];
#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
}

Expand Down

0 comments on commit d33fc1f

Please sign in to comment.