Skip to content

Commit 746b545

Browse files
authored
Merge pull request #515 from rhdeck/fix-readme-swift
Updating readme with improved swift instructions
2 parents a8c4d47 + aba6cb6 commit 746b545

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,30 @@ Add the following code to `AppDelegate.m` (to support iOS 10 and below)
332332
333333
#### Integration of the library with a Swift iOS project
334334
335-
The approach mentioned above should also be possible to employ with Swift. In this case one should have to import `RNAppAuth`
336-
and make `AppDelegate` conform to `RNAppAuthAuthorizationFlowManager`. Note that this has not been tested.
337-
`AppDelegate.swift` should look something like this:
335+
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.
336+
337+
Steps:
338+
339+
1. `swift-Bridging-Header.h` should include a reference to `#import "RNAppAuthAuthorizationFlowManager.h`, like so:
340+
341+
```h
342+
#import <React/RCTBundleURLProvider.h>
343+
#import <React/RCTRootView.h>
344+
#import <React/RCTBridgeDelegate.h>
345+
#import <React/RCTBridge.h>
346+
#import "RNAppAuthAuthorizationFlowManager.h" // <-- Add this header
347+
#if DEBUG
348+
#import <FlipperKit/FlipperClient.h>
349+
// etc...
350+
```
351+
352+
2. `AppDelegate.swift` should implement the `RNAppAuthorizationFlowManager` protocol and have a handler for url deep linking. The result should look something like this:
338353
339354
```swift
340-
@import RNAppAuth
341-
class AppDelegate: UIApplicationDelegate, RNAppAuthAuthorizationFlowManager {
342-
public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate?
355+
@UIApplicationMain
356+
class AppDelegate: UIApplicationDelegate, RNAppAuthAuthorizationFlowManager { //<-- note the additional RNAppAuthAuthorizationFlowManager protocol
357+
public weak var authorizationFlowManagerDelegate: RNAppAuthAuthorizationFlowManagerDelegate? // <-- this property is required by the protocol
358+
//"open url" delegate function for managing deep linking needs to call the resumeExternalUserAgentFlowWithURL method
343359
func application(
344360
_ app: UIApplication,
345361
open url: URL,

0 commit comments

Comments
 (0)