Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

iOS : Failed to load webpage with error: unsupported URL & Failed to display local images #565

Closed
JordanProtin opened this issue Aug 20, 2019 · 0 comments

Comments

@JordanProtin
Copy link

JordanProtin commented Aug 20, 2019

Description

Navigation failure

When I want to navigate in my IONIC 1 app (using angularjs), I get this error:

Failed to load webpage with error: unsupported URL

During debug mode, I saw this error comes from didFailNavigation function in CDVWKWebViewEngine+CodePush.m file:

CDVViewController* vc = (CDVViewController*)self.viewController;
NSString* message = [NSString stringWithFormat:@"Failed to load webpage with error: %@", [error localizedDescription]]; <-- HERE

Display local images failure

I get also this error to display local images. I think it's always a malformed URL issue... Caused by CORS ? I don't know...

Possible track

I think this problem is in relation with cordova-plugin-ionic-webview.
Indeed, this plugin uses WKWebView on iOS and I could see there are many issues between cordova-plugin-code-push and WKWebView... But I'm not sure it comes from it...

Please note all works fine on Android. Therefore I think these issues caused by WKWebView on iOS.

Reproduction

My nav link:

<ion-item ng-href="#/app/preferences">
   <span>Preferences</span>
</ion-item>

When I tap on this link to display another template, I get this error:

Failed to load webpage with error: unsupported URL

My local image:

<div style="background: none; border: none">
   <img ng-src="img/assets/logo.svg">
</div>

Image is not displayed on my view...

Additional Information

  • cordova-plugin-code-push version: ^1.12.0
  • List of installed plugins:
    cordova-plugin-ionic-webview: ^4.1.1
  • Cordova version: ^9.0.0
  • iOS/Android/Windows version: iOS 12.4 (iPhone 8 Plus)
  • Does this reproduce on a debug build or release build? debug and release build. Note works fine when I add livereload option to launch my app using this following command line : ionic cordova run ios. Please note also works fine on a browser using this following command line : ionic serve.

livereload : spin up dev server to live-reload www files

  • Does this reproduce on a simulator, or only on a physical device? ios simulator from xcode

SOLVED :

Sorry for this inconvenience, I think my problem is caused by cordova-plugin-ionic-webview rather than cordova-plugin-code-push.

Add this in .config() in app.js worked for me:

// fix "Failed to load webpage with error: unsupported URL"
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|sms|tel|geo|ftp|mailto|file|ghttps?|ms-appx-web|ms-appx|x-wmapp0|ionic):/);
// sanitize the images to open ionic://localhost/ on iOS
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|content|blob|ms-appx|ms-appx-web|x-wmapp0|ionic):|data:image\//);

Necessary to add ionic keyword because it's the default scheme used on iOS as it's mentioned in this this part

@JordanProtin JordanProtin changed the title iOS : Failed to load webpage with error: unsupported URL iOS : Failed to load webpage with error: unsupported URL & Failed to display local images Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant