首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应-本地[ANDROID]脱下“用”复制件打开

反应-本地[ANDROID]脱下“用”复制件打开
EN

Stack Overflow用户
提问于 2021-02-18 10:32:00
回答 1查看 324关注 0票数 1

描述

我已经描述了我的应用程序的一个深链接意图。

代码语言:javascript
复制
<manifest 
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.company.appname"
>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
    >
      <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustPan"
        android:exported="true"
      >
        <!-- <scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>] -->
        <intent-filter>
          <!-- com.company.appname://logout-->
          <data
            android:scheme="com.company.appname"
            android:host="logout"
          />

          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <action android:name="android.intent.action.VIEW" />
        </intent-filter>
      </activity>

      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

当我跑的时候

代码语言:javascript
复制
npx uri-scheme open com.company.appname://logout --android

我得到了这个提示,它似乎是重复的。

React本地版本:

在您的终端中运行react-native info并在这里复制结果。

代码语言:javascript
复制
System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 4.25 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.8.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0. - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 29
      Build Tools: 29.0.3
      System Images: android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

复制步骤

提供重现问题的详细步骤列表。

  1. 配置与我的AndroidManifest相同的
  2. 运行npx uri-scheme open com.company.appname://logout --android

预期结果

我希望能够看到一个选项的“打开与”提示。

EN

回答 1

Stack Overflow用户

发布于 2021-02-18 11:45:09

我遇到的问题是一个第三方图书馆覆盖了我的意图。

图书馆是https://github.com/FormidableLabs/react-native-app-auth

在我的示例中,为manifestPlaceholders XML中的硬编码intent关闭显示的这里逻辑是一个不错的选择。(https://github.com/openid/AppAuth-android#capturing-the-authorization-redirect)。

e.g

代码语言:javascript
复制
<manifest ...
  xmlns:tools="http://schemas.android.com/tools"
>
  ...
  <activity
        android:name="net.openid.appauth.RedirectUriReceiverActivity"
        tools:node="replace">
    <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:scheme="com.example.app"/>
    </intent-filter>
  </activity>
  ...
</manifest>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66258146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档