微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如果安装了 React Native 重定向到应用程序,否则重定向到 App Store 或 PlayStore

如何解决如果安装了 React Native 重定向到应用程序,否则重定向到 App Store 或 PlayStore

我想在按下应用链接重定向为:-

  1. 如果未安装应用,则转到 Playstore 或 AppStore。
  2. 如果已安装应用,请打开我的应用(带有深层链接)。

到目前为止我所做的:-

我使用 React 导航 5 的深层链接达到了要求 2。 如:-

import constants from '../../constants';

 const config = {
screens: {
    //SignInScreen: "SignInScreen",SignupScreen: {
        path: `${constants.Screens.SignUpScreen.name}/:id`,parse: {
            id: (id) => `${id}`,},}
},};

 const linking = {
prefixes: ["http://com.app"],config,};

 export default linking;

App.js:-

<NavigationContainer linking={linking} ref={navigationRef}>
        {
            props.global.switchApp.isLoading ?
                <SplashStack />
                :
                (
                    props.global.user.accesstoken !== null ?
                        <AppStack /> :
                        <AuthStack />
                )
        }
    </NavigationContainer>

并且 AndroidManifest.xml 中的相应更改为:-

<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="com.app"
      android:scheme="http" />
  </intent-filter>

并在项目的 url type添加 target

Appdelegate.m 文件中为:-

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
        options:(NSDictionary<UIApplicationopenURLOptionsKey,id> *)options {

 // Add any custom logic here.
 BOOL deepLinking =  [RCTLinkingManager application:application openURL:url options:options];
return  deepLinking;
}

我如何在使用它时达到要求 1?

谢谢!!!

解决方法

要打开应用或打开应用商店或 Play 商店,如果应用未安装,请点击应用链接,尝试使用 firebase 动态链接功能。

查看文档了解更多信息。

https://rnfirebase.io/dynamic-links/usage

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。