[英]How to open Viber app in Flutter web app?
I want to open Viber app (Android / Windows) from flutter web application.我想从 Flutter Web 应用程序中打开 Viber 应用程序(Android / Windows)。 I tried using
url_launcher
but it does not work.我尝试使用
url_launcher
但它不起作用。
The URL to open Viber chat is viber://chat?number=xxx
.打开 Viber 聊天的 URL 是
viber://chat?number=xxx
。 How can I call this from flutter web app?我如何从颤动的网络应用程序中调用它?
Found a solution.找到了解决方案。 I used
html
package我用
html
包
import 'dart:html' as html;
After that在那之后
html.window.open('viber://chat?number=xxx', '');
你可以试试这个包Flutter AppAvailability Plugin
Searching for the same solution but only for a mobile app, Google gives me only this question.搜索相同的解决方案但仅针对移动应用程序,Google 只给了我这个问题。 So, I decided to write the research results here.
所以,我决定把研究结果写在这里。 Maybe it will come in handy.
也许它会派上用场。
For a mobile app, you can use url_launcher对于移动应用程序,您可以使用url_launcher
launch('viber://chat?number=$phoneNumber');
If you want to open the conversation with a predefined text, you can write like this:如果你想用预定义的文本打开对话,你可以这样写:
launch('viber://chat/?number=$phoneNumber&draft=$yourMessage');
Please note, if Viber is not installed on your device, the launch
method throws an error.请注意,如果您的设备上未安装 Viber,则
launch
方法会引发错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.