我正在尝试React-Native-Linking和react-native-deep-linking,但是不起作用。
下面的代码只对Skype成功运行,但是如果您打开另一个应用程序,它就不能工作。
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");
}
});
};如果有什么解决办法给我。
发布于 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行
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中的示例/打开应用程序-本机代码
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
https://stackoverflow.com/questions/58877079
复制相似问题