当用户想要订购产品时,我需要打开whatsapp。不幸的是,我遇到了这个错误,我尝试了类似问题的解决方案,但不幸的是 - 没有结果。我将向您展示我的代码的当前版本,也许您可以在那里找到错误并指出它,我将为此感激您。
注意,whatsapp 我从网络视图打开。
这是我的链接打开代码 -
_launchURL(String url) async {
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
}
这是我处理以whatsapp开头的链接的代码...-
webViewController
..setNavigationDelegate(
NavigationDelegate(
onNavigationRequest: (NavigationRequest request) async {
if (request.url.startsWith('https://wa.me/996996969696')) {
List<String> urlSplitted = request.url.split("&text=");
String phone = "996996969696";
String message = urlSplitted.last.toString().replaceAll("%20", " ");
await _launchURL("https://wa.me/$phone/?text=testText}");
// await _launchURL("https://wa.me/$phone/?text=${Uri.parse(message)}");
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
),
)
还有一个细节,一开始运行良好,但几秒钟后出现错误屏幕(截图如下)
我还想向您展示我在清单中的权限 -
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
Webview 版本 - ^4.2.0
Launch_url 版本 - ^6.1.12