[英]How to open flutter web app in browser just like a html file
[英]How to open Viber app in Flutter web app?
我想從 Flutter Web 應用程序中打開 Viber 應用程序(Android / Windows)。 我嘗試使用url_launcher
但它不起作用。
打開 Viber 聊天的 URL 是viber://chat?number=xxx
。 我如何從顫動的網絡應用程序中調用它?
找到了解決方案。 我用html
包
import 'dart:html' as html;
在那之后
html.window.open('viber://chat?number=xxx', '');
你可以試試這個包Flutter AppAvailability Plugin
搜索相同的解決方案但僅針對移動應用程序,Google 只給了我這個問題。 所以,我決定把研究結果寫在這里。 也許它會派上用場。
對於移動應用程序,您可以使用url_launcher
launch('viber://chat?number=$phoneNumber');
如果你想用預定義的文本打開對話,你可以這樣寫:
launch('viber://chat/?number=$phoneNumber&draft=$yourMessage');
請注意,如果您的設備上未安裝 Viber,則launch
方法會引發錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.