Auth0 React Native - 由于地址无效,Safari 无法打开页面

Yak*_* Ad 4 safari callback x-callback-url auth0 react-native

我已经以所有正确的方式做到了这一点,并遇到了这样的问题

https://auth0.com/docs/quickstart/native/react-native/00-login

在此处输入图片说明

Yak*_* Ad 5

原生配置

Auth0 将需要处理托管登录身份验证的回调。

安卓

在文件 android/app/src/main/AndroidManifest.xml 中,您必须确保应用程序的主要活动的 launchMode 值为 singleTask 并且它具有以下意图过滤器。

 <activity
  android:name=".MainActivity"
  android:label="@string/app_name"
  android:launchMode="singleTask"
  android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
  android:windowSoftInputMode="adjustResize">
  <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
      <data
        android:host="yakupad.eu.auth0.com"
        android:pathPrefix="/android/${applicationId}/callback"
        android:scheme="${applicationId}" />
   </intent-filter>
  </activity>
Run Code Online (Sandbox Code Playgroud)

IOS

在文件 ios//AppDelegate.m 中添加以下内容:

 #import <React/RCTLinkingManager.h>

  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
   sourceApplication:(NSString *)sourceApplication annotation:    (id)annotation
   {
      return [RCTLinkingManager application:application openURL:url
                        sourceApplication:sourceApplication       annotation:annotation];
  }
Run Code Online (Sandbox Code Playgroud)

接下来,您需要使用应用程序的包标识符添加 URLScheme。

检查 info.plist 以获取现有的包标识符,例如

 <key>CFBundleIdentifier</key>
 <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier).    </string>
Run Code Online (Sandbox Code Playgroud)

然后,您可以通过添加以下代码段来注册标识符:

 <key>CFBundleURLTypes</key>
 <array>
    <dict>
       <key>CFBundleTypeRole</key>
       <string>None</string>
       <key>CFBundleURLName</key>
       <string>auth0</string>
       <key>CFBundleURLSchemes</key>
       <array>
         <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier).   </string>
    </array>
</dict>
Run Code Online (Sandbox Code Playgroud)