@@ -251,43 +251,39 @@ your `Info.plist` as follows:
251
251
252
252
##### Define openURL callback in AppDelegate
253
253
254
- You need to have a property in your AppDelegate to hold the auth session, in order to continue the
255
- authorization flow from the redirect. To add this, open ` AppDelegate.h ` in your project and add the
256
- following lines:
254
+ You need to retain the auth session, in order to continue the
255
+ authorization flow from the redirect. Follow these steps:
257
256
258
- ``` diff
259
- + @protocol OIDAuthorizationFlowSession;
257
+ ` RNAppAuth ` will call on the given app's delegate via ` [UIApplication sharedApplication].delegate ` .
258
+ Furthermore, ` RNAppAuth ` expects the delegate instance to conform to the protocol ` RNAppAuthAuthorizationFlowManager ` .
259
+ Make ` AppDelegate ` conform to ` RNAppAuthAuthorizationFlowManager ` :
260
260
261
- @interface AppDelegate : UIResponder <UIApplicationDelegate>
262
- + @property(nonatomic, strong, nullable) id<OIDAuthorizationFlowSession> currentAuthorizationFlow;
263
- @property (nonatomic, strong) UIWindow *window;
264
- @end
261
+ ``` diff
262
+ + @interface AppDelegate()<RNAppAuthAuthorizationFlowManager> {
263
+ + id <OIDAuthorizationFlowSession> _currentSession;
264
+ + }
265
+ + @end
265
266
```
266
267
267
- The authorization response URL is returned to the app via the iOS openURL app delegate method, so
268
- you need to pipe this through to the current authorization session (created in the previous
269
- instruction).
270
-
271
- ##### Add a current Authorization session
272
-
273
- To do this, open ` AppDelegate.m ` and add an import statement:
268
+ Implement the required method of ` RNAppAuthAuthorizationFlowManager ` in ` AppDelegate ` :
274
269
275
- ``` Objective-C
276
- #import < AppAuth/AppAuth.h>
270
+ ``` diff
271
+ + -(void)setCurrentAuthorizationFlowSession:(id<OIDAuthorizationFlowSession>)session {
272
+ + // retain session for further use
273
+ + _currentSession = session;
274
+ + }
277
275
```
278
276
279
- And in the bottom of the class, add the following handler:
277
+ The authorization response URL is returned to the app via the iOS openURL app delegate method, so
278
+ you need to pipe this through to the current authorization session (created in the previous
279
+ instruction). Thus, implement the following method from ` UIApplicationDelegate ` in ` AppDelegate ` :
280
280
281
- ``` Objective-C
282
- - (BOOL )application:(UIApplication *)app
283
- openURL:(NSURL *)url
284
- options:(NSDictionary <NSString *, id > *)options {
285
- if ([ _ currentAuthorizationFlow resumeAuthorizationFlowWithURL: url ] ) {
286
- _ currentAuthorizationFlow = nil;
287
- return YES;
288
- }
289
- return NO;
290
- }
281
+ ``` diff
282
+ + - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
283
+ + BOOL shouldOpenUrl = [_currentSession resumeAuthorizationFlowWithURL:url];
284
+ + _currentSession = nil;
285
+ + return shouldOpenUrl;
286
+ + }
291
287
```
292
288
293
289
#### Integration of the library with a Swift iOS project
0 commit comments