Skip to content

Commit cb5061a

Browse files
author
hakonk
committed
feat: implement new pattern in app delegate
1 parent a739cdf commit cb5061a

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Example/ios/AppAuthExample/AppDelegate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
*/
99

1010
#import <UIKit/UIKit.h>
11+
#import <RNAppAuth/RNAppAuthAuthorizationFlowManager.h>
1112

12-
@interface AppDelegate : UIResponder <UIApplicationDelegate>
13+
@interface AppDelegate : UIResponder <UIApplicationDelegate, RNAppAuthAuthorizationFlowManager>
1314
@property (nonatomic, strong, nullable) UIWindow *window;
15+
@property(nonatomic, weak)id<RNAppAuthAuthorizationFlowManagerDelegate>authorizationFlowManagerDelegate;
1416
@end
1517

Example/ios/AppAuthExample/AppDelegate.m

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@
1010
#import "AppDelegate.h"
1111
#import <React/RCTBundleURLProvider.h>
1212
#import <React/RCTRootView.h>
13-
#import <AppAuth/AppAuth.h>
14-
#import <RNAppAuth/RNAppAuthAuthorizationFlowManager.h>
15-
16-
@interface AppDelegate()<RNAppAuthAuthorizationFlowManager> {
17-
id <OIDAuthorizationFlowSession> _currentSession;
18-
}
19-
@end
2013

2114
@implementation AppDelegate
2215

23-
-(void)setCurrentAuthorizationFlowSession:(id<OIDAuthorizationFlowSession>)session {
24-
_currentSession = session;
25-
}
26-
2716
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
2817
{
2918
NSURL *jsCodeLocation;
@@ -45,9 +34,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4534
}
4635

4736
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
48-
BOOL shouldOpenUrl = [_currentSession resumeAuthorizationFlowWithURL:url];
49-
_currentSession = nil;
50-
return shouldOpenUrl;
37+
return [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url];
5138
}
5239

5340
@end

0 commit comments

Comments
 (0)