首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从另一个应用中打开一个应用程序--本地android??

如何从另一个应用中打开一个应用程序--本地android??
EN

Stack Overflow用户
提问于 2019-11-15 12:27:04
回答 1查看 1.9K关注 0票数 2

我正在尝试React-Native-Linkingreact-native-deep-linking,但是不起作用。

下面的代码只对Skype成功运行,但是如果您打开另一个应用程序,它就不能工作。

代码语言:javascript
复制
const checkapp = () => {
  let url = "skype://app";
  Linking.openURL(url).catch(err => {
    if (err.code === "EUNSPECIFIED") {
      if (Platform.OS === "android") {
        AppInstalledChecker.isAppInstalled("skype").then(isInstalled => {
          if (isInstalled) {
            Linking.openURL("url");
          } else {
            console.log("is installed false");
            Linking.openURL(
              "https://play.google.com/store/apps/details?id=com.skype.raider&hl=en"
            ).catch(err => {
              console.log(err);
            });
          }
        });
      }
    } else {
      console.log("Platform Is Ios");
    }
  });
};

如果有什么解决办法给我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-22 06:00:20

100%使用react-native-send-intent打开另一个应用程序的所有应用程序。 响应本地Android模块,使用Android的意图操作来打开第三方应用。

安装npm install react-native-send-intent --save

寄存器模块>= 0.29 (在MainApplication.java中)只增加2行

代码语言:javascript
复制
import com.burnweb.rnsendintent.RNSendIntentPackage;  // <--- import in MainApllication.java

public class MainApplication extends Application implements ReactApplication {
  ......

  @Override
  protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RNSendIntentPackage()); // <------ add this line to your MainApplication 
  class
  }

  ......

  }

在您的react中的示例/打开应用程序-本机代码

代码语言:javascript
复制
 SendIntentAndroid.isAppInstalled('com.medlife.customer').then((isInstalled) => {
            if (isInstalled) {
                SendIntentAndroid.openApp('com.medlife.customer').then((wasOpened) => {
                });
                console.log("is installed true");
            }
            else {
                Linking.openURL('https://play.google.com/store/apps/details?id=com.medlife.customer&hl=en').catch(err => {
                    console.log(err)
                })
            }
        });

我将从我的应用程序中打开第三方Medlife应用程序,如果您需要打开另一个应用程序,那么只需在SendIntentAndroid.openApp('com.medlife.customer')中更改pacakage name

react本机-发送意图的git集线器示例

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58877079

复制
相关文章

相似问题

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