[英]launch method in Flutter url_launcher dart package is deprecated, but launchURL does not have forceSafariVC parameter
Flutter url_launcher dart package 中的“launch”方法已弃用,需要替换为launchURL。 但是 launchURL 方法没有 forceSafariVC 参数。
考虑到 forceSafariVC 参数,迁移到这种新方法会是什么样子?
请改用LaunchMode 。
将 forceSafariVC 和 forceWebView 替换为 LaunchMode,这使得 API 平台中立,并标准化了 Android 和 iOS 之间的默认行为。
请参阅更改日志。
您需要使用LaunchMode
。 一般来说(但并非在所有情况下):
forceSafariVC: false
转换为mode: LaunchMode.externalApplication
。
forceSafariVC: true
转换为mode: LaunchMode.inAppWebView
。
如果您的应用也有非移动目标(macOS、Windows、Linux、Web),那么您可能需要使用不同的模式。
如果您需要处理通用链接,那么您可能需要使用
final nativeAppLaunchSucceeded = await launchUrl(
url,
mode: LaunchMode.externalNonBrowserApplication,
);
if (!nativeAppLaunchSucceeded) {
await launchUrl(
url,
mode: LaunchMode.inAppWebView,
);
}
见官方例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.