简体   繁体   English

React 原生深度链接问题

[英]Issue with React native deep linking

I followed all the steps from both the articles mentioned below我遵循了下面提到的两篇文章中的所有步骤

https://hackernoon.com/react-native-deep-linking-for-ios-and-android-d33abfba7ef3 https://hackernoon.com/react-native-deep-linking-for-ios-and-android-d33abfba7ef3

https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e

After the app gets installed on my phone, I tried opening the app from the browser by giving the URL as peopleapp://people/1 format.在我的手机上安装该应用程序后,我尝试通过将 URL 设为 peopleapp://people/1 格式从浏览器打开该应用程序。 Instead of opening the app, the browser opens Google search to search for the above.浏览器没有打开应用程序,而是打开谷歌搜索来搜索上述内容。

Any idea, how to solve this issue ?任何想法,如何解决这个问题?

Please note that I am using Android请注意,我使用的是 Android

Your issue is caused by the fact the deeplinks work differently on iOS and Android.您的问题是由于深层链接在 iOS 和 Android 上的工作方式不同造成的。

It is true that on iOS you can open a deeplink by typing the link into the browser and it will cause the app to open.确实,在 iOS 上,您可以通过在浏览器中输入链接来打开深层链接,这将导致应用程序打开。

However, for Android to open a deeplink you need to one of three things as it will not open from typing the link into the browser.但是,要让 Android 打开深层链接,您需要执行以下三项操作之一,因为在浏览器中输入链接无法打开。

Edit Configurations编辑配置

The first method is picked exactly from the second tutorial that you mentioned.第一种方法完全是从您提到的第二个教程中选择的。 This is to use the Edit Configurations options in Android Studio.这是为了使用 Android Studio 中的 Edit Configurations 选项。

That is all we need as far as configuration goes.就配置而言,这就是我们所需要的。 To test this out, open Android Studio.要对此进行测试,请打开 Android Studio。 Open Run -> Edit Configurations and change the launch options to URL, passing in the following url: peopleapp://people/1打开 Run -> Edit Configurations 并将启动选项更改为 URL,传入以下 URL: peopleapp://people/1

Android Studio 中的配置图片

Use a Weblink使用网络链接

The second option is to it from a URL that is embeded in a webpage.第二个选项是从嵌入在网页中的 URL 访问它。 The URL should be embeded in an a tag using a href in the following way URL 应该以下列方式使用 href 嵌入到a标签中

<a href="peopleapp://people/1">click me</a>

You then browse to the webpage and click the link.然后浏览到该网页并单击该链接。 That should open the deeplink.那应该打开深层链接。

Deeplink Application深度链接应用

You can use a third party application from the play store that will allow you to open the deeplink.您可以使用 Play 商店中的第三方应用程序来打开深层链接。 There are many to choose from.有很多可供选择。 You can always give https://play.google.com/store/apps/details?id=com.manoj.dlt&hl=en_US a try it seems to have good reviews.您可以随时尝试https://play.google.com/store/apps/details?id=com.manoj.dlt&hl=en_US似乎有很好的评价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM