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