-
Notifications
You must be signed in to change notification settings - Fork 462
Description
Issue
I have installed the react-native-app-auth and done with all three steps that are required for iOS setup:
- Install native dependencies
- Register redirect URL scheme
- Define openURL callback in AppDelegate
Environment
- Your Identity Provider:
Microsoft - Platform that you're experiencing the issue on:
iOS - Your
react-nativeVersion:0.80.2 - Your
react-native-app-authVersion:8.0.3 - Are you using Expo? No
My AppDelegate.swift looks like below:
import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()
reactNativeDelegate = delegate
reactNativeFactory = factory
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative(
withModuleName: "com.myapp",
in: window,
launchOptions: launchOptions
)
return true
}
// Handle OAuth redirect URLs
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
// Forward to React Native’s Linking
return RCTLinkingManager.application(app, open: url, options: options)
}
// Handle Universal Links
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
return RCTLinkingManager.application(
application,
continue: userActivity,
restorationHandler: restorationHandler
)
}
}
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}