如何从另一个应用程序 react-native android 打开一个应用程序?
how to open one app from another app react-native android.?
我正在尝试 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");
}
});
};
如果有解决方案给我。
100% working for open all app from another app using react-native-send-intent
.
React Native Android module to use Android's Intent actions for opening third party apps.
安装
npm install react-native-send-intent --save
注册模块 >= 0.29 (in 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
}
......
}
示例/在您的本机代码中打开应用程序
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)
})
}
});
I am opening 3rd party Medlife
app from my app if you have need to open another app then only change pacakage name
in SendIntentAndroid.openApp('com.medlife.customer')
我正在尝试 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");
}
});
};
如果有解决方案给我。
100% working for open all app from another app using
react-native-send-intent
.React Native Android module to use Android's Intent actions for opening third party apps.
安装
npm install react-native-send-intent --save
注册模块 >= 0.29 (in 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
}
......
}
示例/在您的本机代码中打开应用程序
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)
})
}
});
I am opening 3rd party
Medlife
app from my app if you have need to open another app then only changepacakage name
inSendIntentAndroid.openApp('com.medlife.customer')