如果这适合您,您可以使用 URL 启动器。这样会打开 App Store 或 Play Store,用户可以下载或打开 App。
例如,flutter 有一个包可以完成大部分工作:
https://github.com/Purus/launch_review
LaunchReview.launch(androidAppId: "yourpackagename", iOSAppId: "appid");
你只需要传递你的包名并在 ios 上传递你的应用 ID
您也可以使用 URL 启动器:
https://pub.dev/packages/url_launcher
代码将类似于:
_launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
}
else {
throw 'Could not launch $url';
}
}
网址示例
try {
launch("market://details?id=" + appPackageName);
} on PlatformException catch(e) {
launch("https://play.google.com/store/apps/details?id=" + appPackageName);
} finally {
launch("https://play.google.com/store/apps/details?id=" + appPackageName);
}
注意这段代码需要修改
另请参阅本教程以获取帮助:https://flutteragency.com/open-appstore-playstore-url-in-flutter/
编辑:
如果你想直接打开另一个应用程序,你可以使用这样的东西:
https://pub.dev/packages/external_app_launcher/
flutter pub 添加 external_app_launcher
代码将如下所示:
await LaunchApp.openApp(
androidPackageName: 'net.pulsesecure.pulsesecure',
iosUrlScheme: 'pulsesecure://',
appStoreLink: 'itms-apps://itunes.apple.com/us/app/pulse secure/id945832041',// openStore: false
);
// Enter the package name of the App you want to open and for iOS add the URLscheme to the Info.plist file.
// The `openStore` argument decides whether the app redirects to PlayStore or AppStore.
// For testing purpose you can enter com.instagram.android
您可以在此处找到有关实施和其他设置信息的更多信息:自述文件中的https://pub.dev/packages/external_app_launcher