@@ -213,7 +213,7 @@ AppAuth supports three options for dependency management.
213
213
214
214
pod 'AppAuth', '>= 0.94'
215
215
216
- Then run ` pod install ` . Note that version 0.91 is the first of the library to support iOS 11.
216
+ Then run ` pod install ` . Note that version 0.94 is the first of the library to support iOS 11.
217
217
218
218
2 . ** Carthage**
219
219
@@ -265,58 +265,39 @@ authorization flow from the redirect. Follow these steps:
265
265
266
266
` RNAppAuth ` will call on the given app's delegate via ` [UIApplication sharedApplication].delegate ` .
267
267
Furthermore, ` RNAppAuth ` expects the delegate instance to conform to the protocol ` RNAppAuthAuthorizationFlowManager ` .
268
- Make ` AppDelegate ` conform to ` RNAppAuthAuthorizationFlowManager ` :
268
+ Make ` AppDelegate ` conform to ` RNAppAuthAuthorizationFlowManager ` with the following changes to ` AppDelegate.h ` :
269
269
270
270
``` diff
271
- + // Depending on build configurations, import either with:
272
- + @import RNAppAuth;
273
- + // or:
274
- + import <AppAuth/AppAuth.h>
275
- + import "RNAppAuthAuthorizationFlowManager.h"
276
-
277
- + @interface AppDelegate()<RNAppAuthAuthorizationFlowManager> {
278
- + id <OIDAuthorizationFlowSession> _currentSession;
279
- + }
280
- + @end
281
- ```
282
-
283
- Implement the required method of ` RNAppAuthAuthorizationFlowManager ` in ` AppDelegate ` :
284
-
285
- ``` diff
286
- + -(void)setCurrentAuthorizationFlowSession:(id<OIDAuthorizationFlowSession>)session {
287
- + // retain session for further use
288
- + _currentSession = session;
289
- + }
271
+ + #import <RNAppAuth/RNAppAuthAuthorizationFlowManager.h>
272
+ + @interface AppDelegate : UIResponder <UIApplicationDelegate, RNAppAuthAuthorizationFlowManager>
273
+ + @property(nonatomic, weak)id<RNAppAuthAuthorizationFlowManagerDelegate>authorizationFlowManagerDelegate;
290
274
```
291
275
292
276
The authorization response URL is returned to the app via the iOS openURL app delegate method, so
293
277
you need to pipe this through to the current authorization session (created in the previous
294
- instruction). Thus, implement the following method from ` UIApplicationDelegate ` in ` AppDelegate ` :
278
+ instruction). Thus, implement the following method from ` UIApplicationDelegate ` in ` AppDelegate.m ` :
295
279
296
280
``` diff
297
281
+ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
298
- + BOOL shouldOpenUrl = [_currentSession resumeAuthorizationFlowWithURL:url];
299
- + _currentSession = nil;
300
- + return shouldOpenUrl;
282
+ + return return [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url];
301
283
+ }
302
284
```
303
285
304
286
#### Integration of the library with a Swift iOS project
305
287
306
288
The approach mentioned above should also be possible to employ with Swift. In this case one should have to import ` RNAppAuth `
307
289
and make ` AppDelegate ` conform to ` RNAppAuthAuthorizationFlowManager ` . Note that this has not been tested.
308
- ` AppDelegate ` should look something like this:
290
+ ` AppDelegate.swift ` should look something like this:
309
291
310
292
``` swift
311
293
@import RNAppAuth
312
294
class AppDelegate : UIApplicationDelegate , RNAppAuthAuthorizationFlowManager {
313
- private var currentAuthorizationFlow: OIDAuthorizationFlowSession ?
295
+ public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate ?
314
296
func application (
315
297
_ app : UIApplication,
316
298
open url : URL,
317
299
options : [UIApplicationOpenURLOptionsKey: Any ] = [: ]) -> Bool {
318
- defer { currentAuthorizationFlow = nil }
319
- return currentAuthorizationFlow? .resumeAuthorizationFlow (with : url) ?? false
300
+ return authorizationFlowManagerDelegate? .resumeExternalUserAgentFlowWithURL (with : url) ?? false
320
301
}
321
302
}
322
303
```
0 commit comments