FormidableLabs / FormidableLabs/react-native-app-auth

React Native iOS app crashed when used react-native-app-auth

Open
#1,085 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
473
PR merge metrics
No merged PRs in 30d

Description

## Issue
I have installed the react-native-app-auth and done with all three steps that are required for iOS setup:

1. Install native dependencies
2. Register redirect URL scheme
3. Define openURL callback in AppDelegate

## Environment
* **Your Identity Provider**: `Microsoft`
* **Platform that you're experiencing the issue on**: `iOS`
* **Your `react-native` Version**: `0.80.2`
* **Your `react-native-app-auth` Version**: `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
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.