You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/introduction.md
+75-40Lines changed: 75 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,9 @@ Get started by installing the dependencies in your application
10
10
```sh
11
11
yarn add react-native-app-auth
12
12
```
13
+
13
14
Or
15
+
14
16
```sh
15
17
npm install react-native-app-auth --save
16
18
```
@@ -115,9 +117,79 @@ your `Info.plist` as follows:
115
117
You need to retain the auth session, in order to continue the
116
118
authorization flow from the redirect. Follow these steps:
117
119
118
-
`RNAppAuth` will call on the given app's delegate via `[UIApplication sharedApplication].delegate`.
119
-
Furthermore, `RNAppAuth` expects the delegate instance to conform to the protocol `RNAppAuthAuthorizationFlowManager`.
120
-
Make `AppDelegate` conform to `RNAppAuthAuthorizationFlowManager` with the following changes to `AppDelegate.h`:
120
+
###### For react-native >= 0.77
121
+
122
+
As of `[email protected]`, the `AppDelegate` template is now written in Swift.
123
+
124
+
In order to bridge to the existing Objective-C code that this package utilizes, you need to create a bridging header file. To do so:
125
+
126
+
1. Create a new file in your project called `AppDelegate+RNAppAuth.h`. (It can be called anything, but it must end with `.h`)
127
+
2. Add the following code to the file:
128
+
129
+
```
130
+
#import "RNAppAuthAuthorizationFlowManager.h"
131
+
```
132
+
133
+
3. Ensure that your XCode "Build Settings" has the following `Objective-C Bridging Header` path set to the file you just created. For example, it make look something like: `$(SRCROOT)/AppDelegate+RNAppAuth.h`
134
+
135
+
4. Add the following code to `AppDelegate.swift` to support React Navigation deep linking and overriding browser behavior in the authorization process
136
+
137
+
```swift
138
+
@main
139
+
class AppDelegate: UIResponder, UIApplicationDelegate,
140
+
RNAppAuthAuthorizationFlowManager {
141
+
//... existing code...
142
+
// Required by RNAppAuthAuthorizationFlowManager protocol
@@ -199,45 +271,8 @@ If you want to support universal links, add the following to `AppDelegate.m` und
199
271
+ }
200
272
```
201
273
202
-
#### Integration of the library with a Swift iOS project
203
-
204
-
The approach mentioned should work with Swift. In this case one should make `AppDelegate` conform to `RNAppAuthAuthorizationFlowManager`. Note that this is not tested/guaranteed by the maintainers.
205
-
206
-
Steps:
207
-
208
-
1. `swift-Bridging-Header.h` should include a reference to `#import "RNAppAuthAuthorizationFlowManager.h`, like so:
209
-
210
-
```h
211
-
#import <React/RCTBundleURLProvider.h>
212
-
#import <React/RCTRootView.h>
213
-
#import <React/RCTBridgeDelegate.h>
214
-
#import <React/RCTBridge.h>
215
-
#import "RNAppAuthAuthorizationFlowManager.h" // <-- Add this header
216
-
#if DEBUG
217
-
#import <FlipperKit/FlipperClient.h>
218
-
// etc...
219
-
```
220
-
221
-
2. `AppDelegate.swift` should implement the `RNAppAuthAuthorizationFlowManager` protocol and have a handler for url deep linking. The result should look something like this:
222
-
223
-
```swift
224
-
@UIApplicationMain
225
-
class AppDelegate: UIApplicationDelegate, RNAppAuthAuthorizationFlowManager { //<-- note the additional RNAppAuthAuthorizationFlowManager protocol
226
-
public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate? // <-- this property is required by the protocol
227
-
//"open url" delegate functionfor managing deep linking needs to call the resumeExternalUserAgentFlowWithURL method
**Note:**forRN >= 0.57, you will get a warning about compile being obsolete. To get rid of this warning, use [patch-package](https://github.com/ds300/patch-package) to replace compile with implementation [asin this PR](https://github.com/FormidableLabs/react-native-app-auth/pull/242) - we're not deploying this right now, because it would break the build for RN < 57.
240
-
241
276
To setup the Android project, you need to add redirect scheme manifest placeholder:
242
277
243
278
To [capture the authorization redirect](https://github.com/openid/AppAuth-android#capturing-the-authorization-redirect),
0 commit comments