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.27k stars 1.61k forks source link

Local urls not resolving on IOS platform #2254

Open YoofiBP opened 2 months ago

YoofiBP commented 2 months ago

Environment

Technology Version
Flutter version 3.16.8
Plugin version 6.0.0
Android version
iOS version 17
macOS version
Xcode version
Google Chrome version

Device information: Simulator and 11 Pro Max

I have added the plugin for in app web view to my flutter project. I have html content as string with file urls embedded in media tags and want to render this in my web view

Expected behavior: Files load on all platforms

Current behavior: The local file urls resolve on Android but not on iOS. I have added the required options from the docs but still not clear how to get these to show in IOS

Steps to reproduce

HTML Content: <p> Let's see if this works</p><p> <img src="file:///var/mobile/Containers/Data/Application/A9C87532-47D9-4959-B2ED-E589AFF11F22/Documents/media/institutions/1/courses/1/sessions/7596/img1_1603362234.png" alt="" width="100%"> </img></p><p></p><p> Another image</p><p> <img src="file:///var/mobile/Containers/Data/Application/A9C87532-47D9-4959-B2ED-E589AFF11F22/Documents/media/institutions/1/courses/1/sessions/7596/img2_1603362234.jpeg" alt="" width="100%"> </img></p>

InAppWebView( key: GlobalKey(), // windowId: controller.currentPage.value, initialSettings: InAppWebViewSettings( allowFileAccessFromFileURLs: true, allowUniversalAccessFromFileURLs: true, allowFileAccess: true, allowContentAccess: true ), initialData: InAppWebViewInitialData(data: loadHtmlFromAssets(content)), initialOptions: InAppWebViewGroupOptions( crossPlatform: InAppWebViewOptions( supportZoom: true, javaScriptEnabled: true, disableHorizontalScroll: true, disableVerticalScroll: false, allowFileAccessFromFileURLs: true, allowUniversalAccessFromFileURLs: true ), ), );

Info.plist

`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

io.flutter.embedded_views_preview BGTaskSchedulerPermittedIdentifiers com.transistorsoft.checkForUpdatesAndNotify com.transistorsoft.sendQueuedNetworkRequests com.transistorsoft.runQueuedNetworkRequests com.transistorsoft.fetch CADisableMinimumFrameDurationOnPhone CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleLocalizations en fr es sw NSPhotoLibraryUsageDescription Users may be able to submit files from their filesystem as a response to survey CFBundlePackageType APPL CFBundleShortVersionString $(FLUTTER_BUILD_NAME) CFBundleSignature ???? CFBundleVersion $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS UIApplicationSupportsIndirectInputEvents UIBackgroundModes fetch processing UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance NSAppTransportSecurity NSAllowsArbitraryLoads NSAllowsLocalNetworking NSAllowsArbitraryLoadsInWebContent `
github-actions[bot] commented 2 months ago

👋 @YoofiBP

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!