【问题标题】:Auth0 React Native - Safari cannot open the page because the address is invalidAuth0 React Native - Safari 无法打开页面,因为地址无效
【发布时间】:2018-01-05 12:46:31
【问题描述】:

我以所有正确的方式做到了这一点,并遇到了这样的problem

【问题讨论】:

    标签: react-native safari callback auth0 x-callback-url


    【解决方案1】:

    本机配置

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

    安卓

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

     <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>
    

    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];
      }
    

    接下来,您需要使用应用的捆绑标识符添加 URLScheme。

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

     <key>CFBundleIdentifier</key>
     <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier).    </string>
    

    然后您可以通过添加以下 sn -p 来注册标识符:

     <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多