pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.01k stars 1.33k forks source link

maintain bottomnavbar and appbar when viewing instagram stories #2084

Open Patiyang opened 1 month ago

Patiyang commented 1 month ago

Environment

Technology Version
Flutter version 3.9.4
Plugin version 6.0.0
Android version 12
iOS version
macOS version
Xcode version
Google Chrome version

Device information:

Description

I need to be able to display the instagram stories within the appbar and bottomnavbar. Any ideas on any changes I could make to my code

Expected behavior: Allow the webview to show the appbar and bottomnavbar when viewing instagram stories current behavior: not displaying the appbar and bottomnavbar when viewing instagram stories

Steps to reproduce

InAppWebView( key: webViewKey,

          // webViewEnvironment: webViewEnvironment,
          initialUrlRequest: URLRequest(url: WebUri(urlController.text.isEmpty ? 'https://www.instagram.com' : urlController.text)),

          initialUserScripts: UnmodifiableListView<UserScript>([]),
          initialSettings: settings,
          contextMenu: contextMenu,

          pullToRefreshController: pullToRefreshController,
          onWebViewCreated: (controller) async {
            webViewController = controller;
          },
          onLoadStart: (controller, url) async {
            setState(() {
              this.url = url.toString();
              urlController.text = this.url;
            });
          },
          onPermissionRequest: (controller, request) async {
            return PermissionResponse(resources: request.resources, action: PermissionResponseAction.GRANT);
          },
          shouldOverrideUrlLoading: (controller, navigationAction) async {
            var uri = navigationAction.request.url!;

            if (!["http", "https", "file", "chrome", "data", "javascript", "about"].contains(uri.scheme)) {
              if (await canLaunchUrl(uri)) {
                // Launch the App
                await launchUrl(
                  uri,
                );
                // and cancel the request
                return NavigationActionPolicy.CANCEL;
              }
            }

            return NavigationActionPolicy.ALLOW;
          },
          onLoadStop: (controller, url) async {
            pullToRefreshController?.endRefreshing();

            if (url.toString() == 'https://www.instagram.com/') {
              final gotCookies = await _cookieManager.getCookies('https://www.instagram.com');
              String cookie = '';

              Map cookieList = gotCookies.reversed.toList().asMap();
              if (cookieList.values.firstWhereOrNull((element) => element.name == 'sessionid') != null) {
                cookieList.forEach((key, value) {
                  if (value.name == 'sessionid' || value.name == 'csrftoken' || value.name == 'ds_user_id') {
                    cookie += '${value.name}=${value.value.split(';').first};';
                  }
                });
              }
              SharedPrefs().saveSessionId(cookie);
              // _addButtonToInstagramMedia();
            }
            setState(() {
              this.url = url.toString();
              urlController.text = this.url;
            });
          },);

https://github.com/pichillilorenzo/flutter_inappwebview/assets/46455682/fa6a2dcf-95dc-4118-b44b-c7a4f80d8f0c

  1. This
  2. Than that
  3. Then

Images

Stacktrace/Logcat

github-actions[bot] commented 1 month ago

👋 @Patiyang

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!