Posts

Post not yet marked as solved
1 Replies
723 Views
I want to detect the response MimeType so that accordingly handle the type of file that's being downloaded. So, for example, if the file type is `application/vnd.ms-excel` then I want to take certain action but, with WKWebView it is always returning `text/html` in `-(void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler`I noticed that if I debug the WKWebView using Safari then the response MimeType is correctly displaying as `application/vnd.ms-excel` but, maybe because of QuickLook feature available in WkWebView the content is getting converted into HTML and responding `text/html`.Is there any way to detect the mimeType apart from the above option that returns the actual file's mimeType?
Posted
by jatinb.
Last updated
.
Post not yet marked as solved
1 Replies
3.8k Views
My App has In-App Browser. I used `WKWebView` for providing a Browsing feature within the app. So, currently, whenever a User is opening PDF in WKWebView it gets rendered within the WebView first and then if he/she wants to download, we have provided an option to download the PDF where we're making a separate download task call using+ (NSURLSession *)sessionWithConfiguration:(NSURLSessionConfiguration *)configuration delegate:(nullable id )delegate delegateQueue:(nullable NSOperationQueue *)queue;Now, the issue is with the download part where I am making a separate request. If user tries to download any file which is HTTP based, the download task gets failed with below error:{"info":"Error Domain=NSURLErrorDomain Code=-1022 \"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.\" UserInfo={NSUnderlyingError=0x600001fe36f0 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 \"(null)\"}, NSErrorFailingURLStringKey=http://www.africau.edu/images/default/sample.pdf, NSErrorFailingURLKey=http://www.africau.edu/images/default/sample.pdf, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}","error":"NSURLErrorDomain","url":"http://www.africau.edu/images/default/sample.pdf"}In Info.plist I have set<plist version="1.0"> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> </dict></plist>So, I assumed that It should allow HTTP requests but, here Its not happening so, if anyone has any clue then please help.Thanks in Advance!
Posted
by jatinb.
Last updated
.