Skip to content

Commit 8bf6662

Browse files
author
hakonk
committed
feat: implement RNAppAuthAuthorizationFlowManager in app delegate in example project
1 parent dd8dd75 commit 8bf6662

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Example/ios/AppAuthExample/AppDelegate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
#import <UIKit/UIKit.h>
1111

12-
@protocol OIDAuthorizationFlowSession;
13-
1412
@interface AppDelegate : UIResponder <UIApplicationDelegate>
15-
@property(nonatomic, strong, nullable) id<OIDAuthorizationFlowSession> currentAuthorizationFlow;
1613
@property (nonatomic, strong, nullable) UIWindow *window;
17-
1814
@end
1915

Example/ios/AppAuthExample/AppDelegate.m

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@
88
*/
99

1010
#import "AppDelegate.h"
11-
1211
#import <React/RCTBundleURLProvider.h>
1312
#import <React/RCTRootView.h>
1413
#import <AppAuth/AppAuth.h>
14+
#import <RNAppAuth/RNAppAuthAuthorizationFlowManager.h>
15+
16+
@interface AppDelegate()<RNAppAuthAuthorizationFlowManager> {
17+
id <OIDAuthorizationFlowSession> _currentSession;
18+
}
19+
@end
1520

1621
@implementation AppDelegate
1722

23+
-(void)setCurrentAuthorizationFlowSession:(id<OIDAuthorizationFlowSession>)session {
24+
_currentSession = session;
25+
}
26+
1827
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
1928
{
2029
NSURL *jsCodeLocation;
@@ -35,14 +44,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3544
return YES;
3645
}
3746

38-
- (BOOL)application:(UIApplication *)app
39-
openURL:(NSURL *)url
40-
options:(NSDictionary<NSString *, id> *)options {
41-
if ([_currentAuthorizationFlow resumeAuthorizationFlowWithURL:url]) {
42-
_currentAuthorizationFlow = nil;
43-
return YES;
44-
}
45-
return NO;
47+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
48+
BOOL shouldOpenUrl = [_currentSession resumeAuthorizationFlowWithURL:url];
49+
_currentSession = nil;
50+
return shouldOpenUrl;
4651
}
4752

4853
@end

0 commit comments

Comments
 (0)