Skip to content

Commit 16e9b38

Browse files
authored
Chore: Readme update (#900)
* chore: Update readme for RN 0.68+ setup instructions * chore: add changeset
1 parent 6c0b1d0 commit 16e9b38

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

.changeset/eighty-emus-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-app-auth': patch
3+
---
4+
5+
Readme update for RN 0.68+ setup

README.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This library _should_ support any OAuth provider that implements the
2121

2222
We only support the [Authorization Code Flow](https://oauth.net/2/grant-types/authorization-code/).
2323

24-
### Tested OpenID providers
24+
## Tested OpenID providers
2525

2626
These providers are OpenID compliant, which means you can use [autodiscovery](https://openid.net/specs/openid-connect-discovery-1_0.html).
2727

@@ -36,7 +36,7 @@ These providers are OpenID compliant, which means you can use [autodiscovery](ht
3636
- [AWS Cognito](https://eu-west-1.console.aws.amazon.com/cognito) ([Example configuration](./docs/config-examples/aws-cognito.md))
3737
- [Asgardeo](https://asgardeo.io) ([Example configuration](./docs/config-examples/asgardeo.md))
3838

39-
### Tested OAuth2 providers
39+
## Tested OAuth2 providers
4040

4141
These providers implement the OAuth2 spec, but are not OpenID providers, which means you must configure the authorization and token endpoints yourself.
4242

@@ -261,10 +261,15 @@ This is the result from the auth server
261261

262262
## Getting started
263263

264+
```sh
265+
yarn add react-native-app-auth
266+
```
267+
Or
264268
```sh
265269
npm install react-native-app-auth --save
266270
```
267271

272+
268273
## Setup
269274

270275
### iOS Setup
@@ -275,7 +280,7 @@ To setup the iOS project, you need to perform three steps:
275280
2. [Register redirect URL scheme](#register-redirect-url-scheme)
276281
3. [Define openURL callback in AppDelegate](#define-openurl-callback-in-appdelegate)
277282

278-
##### Install native dependencies
283+
#### Install native dependencies
279284

280285
This library depends on the native [AppAuth-ios](https://github.com/openid/AppAuth-iOS) project. To
281286
keep the React Native library agnostic of your dependency management method, the native libraries
@@ -314,7 +319,7 @@ AppAuth supports three options for dependency management.
314319
4. Add `AppAuth-iOS/Source` to your search paths of your target ("Build Settings -> "Header Search
315320
Paths").
316321
317-
##### Register redirect URL scheme
322+
#### Register redirect URL scheme
318323
319324
If you intend to support iOS 10 and older, you need to define the supported redirect URL schemes in
320325
your `Info.plist` as follows:
@@ -338,7 +343,7 @@ your `Info.plist` as follows:
338343
beginning of your OAuth Redirect URL, up to the scheme separator (`:`) character. E.g. if your redirect uri
339344
is `com.myapp://oauth`, then the url scheme will is `com.myapp`.
340345
341-
##### Define openURL callback in AppDelegate
346+
#### Define openURL callback in AppDelegate
342347
343348
You need to retain the auth session, in order to continue the
344349
authorization flow from the redirect. Follow these steps:
@@ -347,6 +352,54 @@ authorization flow from the redirect. Follow these steps:
347352
Furthermore, `RNAppAuth` expects the delegate instance to conform to the protocol `RNAppAuthAuthorizationFlowManager`.
348353
Make `AppDelegate` conform to `RNAppAuthAuthorizationFlowManager` with the following changes to `AppDelegate.h`:
349354
355+
##### For react-native >= 0.68
356+
Example setup can be see in the [Example app](./Example/ios)
357+
358+
```diff
359+
+ #import <React/RCTLinkingManager.h>
360+
+ #import "RNAppAuthAuthorizationFlowManager.h"
361+
362+
- @interface AppDelegate : RCTAppDelegate
363+
+ @interface AppDelegate : RCTAppDelegate <RNAppAuthAuthorizationFlowManager>
364+
365+
+ @property(nonatomic, weak) id<RNAppAuthAuthorizationFlowManagerDelegate> authorizationFlowManagerDelegate;
366+
```
367+
368+
Add the following code to `AppDelegate.mm` to support React Navigation deep linking and overriding browser behavior in the authorization process
369+
370+
```diff
371+
+ - (BOOL) application: (UIApplication *)application
372+
+ openURL: (NSURL *)url
373+
+ options: (NSDictionary<UIApplicationOpenURLOptionsKey, id> *) options
374+
+ {
375+
+ if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
376+
+ return YES;
377+
+ }
378+
+ return [RCTLinkingManager application:application openURL:url options:options];
379+
+ }
380+
```
381+
382+
If you want to support universal links, add the following to `AppDelegate.mm` under `continueUserActivity`
383+
384+
```diff
385+
+ - (BOOL) application: (UIApplication *) application
386+
+ continueUserActivity: (nonnull NSUserActivity *)userActivity
387+
+ restorationHandler: (nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
388+
+ {
389+
+ if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
390+
+ if (self.authorizationFlowManagerDelegate) {
391+
+ BOOL resumableAuth = [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:userActivity.webpageURL];
392+
+ if (resumableAuth) {
393+
+ return YES;
394+
+ }
395+
+ }
396+
+ }
397+
+ return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
398+
+ }
399+
```
400+
401+
##### For react-native < 0.68
402+
350403
```diff
351404
+ #import "RNAppAuthAuthorizationFlowManager.h"
352405

0 commit comments

Comments
 (0)