WhatsApp Web台式机模式扑来

发布于 2025-01-28 02:22:15 字数 2594 浏览 3 评论 0原文

我想在我的Flutter应用程序中打开WhatsApp Web桌面模式 如图所示 必需的结果

我被使用 webview_flutter webview_flutter_flutter_plutter_plust webview_flutter_plus same and case and case。

我的最初URL是

https://web.whatsapp.com

我使用的代码如下

class WhatsAppWebScreen extends StatefulWidget {
  WhatsAppWebScreen({Key? key}) : super(key: key);

  // late Completer<WebViewController> controller;

  @override
  State<WhatsAppWebScreen> createState() => _WhatsAppWebScreenState();
}

class _WhatsAppWebScreenState extends State<WhatsAppWebScreen> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: const DrawerWidget(),
      appBar: AppBar(
        title: const Text("WhatsAppWeb"),
        backgroundColor: Color(0xFF128D7E),
      ),
      body: SingleChildScrollView(
        child: Container(
          height: 80.h,
          child: WebViewPlus(
            initialUrl: 'https://web.whatsapp.com',
          
            userAgent:
               "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
            javascriptMode: JavascriptMode.unrestricted,
          ),
        ),
      ),
    );
  }
}

每次我运行此代码时,URL都会重定向到

www.whatsapp.com

和类似这样的结果

在此处输入图像描述

我尝试了许多不同的用户代理字符串,但结果相同。

我使用NavigationDelegate参数来防止重定向URL。但是后来显示空白屏幕,

navigationDelegate: (request) {
       if (request.url.startsWith('https://www.whatsapp.com/')) {
         print('blocking navigation to $request}');
       
         return NavigationDecision.prevent;
       }
      print('allowing navigation to $request');
       return NavigationDecision.navigate;
    },
    onWebViewCreated: (webViewController) {
       _controller.complete(webViewController);
     },

我如何在flutter应用中打开WhatsApp Web桌面模式?

I want to open Whatsapp Web Desktop mode in my flutter app
As shown in picture
Required Result

I am used webview_flutter webview_flutter_plus packages but both results same.

my initial url is

https://web.whatsapp.com

The code i am using are as follow

class WhatsAppWebScreen extends StatefulWidget {
  WhatsAppWebScreen({Key? key}) : super(key: key);

  // late Completer<WebViewController> controller;

  @override
  State<WhatsAppWebScreen> createState() => _WhatsAppWebScreenState();
}

class _WhatsAppWebScreenState extends State<WhatsAppWebScreen> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: const DrawerWidget(),
      appBar: AppBar(
        title: const Text("WhatsAppWeb"),
        backgroundColor: Color(0xFF128D7E),
      ),
      body: SingleChildScrollView(
        child: Container(
          height: 80.h,
          child: WebViewPlus(
            initialUrl: 'https://web.whatsapp.com',
          
            userAgent:
               "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
            javascriptMode: JavascriptMode.unrestricted,
          ),
        ),
      ),
    );
  }
}

Every Time i run this code the url redirects into

www.whatsapp.com

and results like this

enter image description here

I try many different user agents strings but the same result.

I used navigationdelegate parameter to prevent redirection of url. but then it shows blank screen

navigationDelegate: (request) {
       if (request.url.startsWith('https://www.whatsapp.com/')) {
         print('blocking navigation to $request}');
       
         return NavigationDecision.prevent;
       }
      print('allowing navigation to $request');
       return NavigationDecision.navigate;
    },
    onWebViewCreated: (webViewController) {
       _controller.complete(webViewController);
     },

How can i open whatsapp web desktop mode in my flutter app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清晨说晚安 2025-02-04 02:22:15
WebView(
        initialUrl: 'https://web.whatsapp.com',
      
        userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        javascriptMode: JavascriptMode.unrestricted,
      ),
WebView(
        initialUrl: 'https://web.whatsapp.com',
      
        userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
        javascriptMode: JavascriptMode.unrestricted,
      ),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文