PDFJ в .NET MAUI WebView на iOS ⇐ IOS
-
Гость
PDFJ в .NET MAUI WebView на iOS
I'm trying to use PDFJs in a WebView to load a locally stored file in the apps data directory. It works fine on my iOS simulator, however, once I put the build into TestFlight and test on a real device, PDFJs loads and throws exception missing_file_error.
I have added the following to my MauiProgram.cs:
#if IOS || MACCATALYST if (handler.PlatformView is WKWebView wkWebView) { wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("allowFileAccessFromFileURLs")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(false), new NSString("secureContextChecksEnabled")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("fileSystemAccessEnabled")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("storageAPIEnabled")); } #endif The following to my Info.plist:
NSAppTransportSecurity NSAllowsArbitraryLoads NSAllowsArbitraryLoadsForMedia NSAllowsArbitraryLoadsInWebContent NSAllowsLocalNetworking NSExceptionAllowsInsecureHTTPLoads
Источник: https://stackoverflow.com/questions/780 ... iew-on-ios
I'm trying to use PDFJs in a WebView to load a locally stored file in the apps data directory. It works fine on my iOS simulator, however, once I put the build into TestFlight and test on a real device, PDFJs loads and throws exception missing_file_error.
I have added the following to my MauiProgram.cs:
#if IOS || MACCATALYST if (handler.PlatformView is WKWebView wkWebView) { wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("allowFileAccessFromFileURLs")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(false), new NSString("secureContextChecksEnabled")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("fileSystemAccessEnabled")); wkWebView.Configuration.Preferences.SetValueForKey(Foundation.NSObject.FromObject(true), new NSString("storageAPIEnabled")); } #endif The following to my Info.plist:
NSAppTransportSecurity NSAllowsArbitraryLoads NSAllowsArbitraryLoadsForMedia NSAllowsArbitraryLoadsInWebContent NSAllowsLocalNetworking NSExceptionAllowsInsecureHTTPLoads
Источник: https://stackoverflow.com/questions/780 ... iew-on-ios
Мобильная версия