Open Anuj-logiciel opened 4 years ago
We're also experiencing problems at my client when using WKWebView, which is a shame because we would love to use both CodePush and WKWebView.
So far we've tested both cordova-plugin-ionic-webview
as well as cordova-plugin-wkwebview-engine
for our Ionic 3 application. When the application gets restarted after installing the CodePush update, we just see a white screen. When looking at the history tab in Safari we can see that it tries to find the index.html file from the downloaded bundle at some path under the ionic://localhost
protocol. I'm not sure if it's actually able to find it (I guess not?), but at least we do not get any 404 errors.
It would be great if we could updates from the people at Microsoft regarding this (there are multiple issues posted about WKWebView), so we know whether or not we can expect a fix to be implemented shortly.
You might want to post the specific versions of your plugins etc.
We are running an app with cordova-plugin-ionic-webview and the latest codepush in production without issue.
However we are using cordova-plugin-ionic-webview 2.5.2 to preserve the "old" url scheme format.
For adding info to my issue, I would like to add more info here-
I am using - This WKWebview plugin
I also have Also reported issue on its plugin.
Has anyone tried the cordova-plugin-wkwebview-file-xhr
plugin to see if it works with code push?
https://github.com/oracle/cordova-plugin-wkwebview-file-xhr
following this issue...
Following this issue...
Same issue here I did try by installing cordova-plugin-wkwebview-file-xhr (even though we already have https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix) and the behavior is exactly the same:
FYI, we are not experiencing any issues with codepush with these versions:
<engine name="ios" spec="^5.1.1" />
<plugin name="cordova-plugin-zip" spec="^3.1.0" />
<plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
<plugin name="cordova-plugin-file" spec="^4.3.1" />
<plugin name="cordova-plugin-code-push" spec="^1.12.0" />
<plugin name="cordova-plugin-wkwebview-engine" spec="^1.2.1" />
<plugin name="cordova-plugin-wkwebviewxhrfix" spec="git+https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git" />
The code-push plugin (not declared in config.xml) is at slightly older 3.0.1. Our initial update is usually installed on app restart and subsequent updates are installed on app resume.
FYI, we are not experiencing any issues with codepush with these versions:
<engine name="ios" spec="^5.1.1" /> <plugin name="cordova-plugin-zip" spec="^3.1.0" /> <plugin name="cordova-plugin-file-transfer" spec="^1.7.1" /> <plugin name="cordova-plugin-file" spec="^4.3.1" /> <plugin name="cordova-plugin-code-push" spec="^1.12.0" /> <plugin name="cordova-plugin-wkwebview-engine" spec="^1.2.1" /> <plugin name="cordova-plugin-wkwebviewxhrfix" spec="git+https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git" />
The code-push plugin (not declared in config.xml) is at slightly older 3.0.1. Our initial update is usually installed on app restart and subsequent updates are installed on app resume.
Hi Alex,
Can you please clarify what you mean by "the code-push plugin...is slightly older 3.0.1"? This is not a valid version for cordova-plugin-code-push, and the version listed in your config.xml is 1.12.0.
I am also have issues getting code push to work with WkWebView, and I am trying to replicate your setup.
code-push is an 'internal' dependency of the cordova-plugin-code-push and has its own plugin package and version. If you install from scratch, I think you'll get a newer version of code-push than 3.0.1 right now as it gets the latest, but since we had it previously and it satisfies the dependency requirement, it gets used. I don't know if the older version matters or not.
Thank you alexhisen, it worked for me
Hi there Finally being forced by Apple we had to step into, and this issue seems to have been a space in our Project Name https://github.com/microsoft/cordova-plugin-code-push/issues/618
Hi there!
@Anuj-logiciel Could you please test your project with new changes?
Hi all,
We merged this PR https://github.com/microsoft/cordova-plugin-code-push/pull/642 and published new 1.13.1
version. Could you please test it and let us know if it fixed your issue?
Hi Alexander,
1.13.1 did not fix the issue for me. The error message "Failed to load webpage with error: unsupported URL" now pops up as an alert instead of just in the XCode output.
I also tried updating the code-push dependency plugin from 3.0.1 to 4.0.2. The same error pops up when starting the app as before.
My Objective-C skills are very rusty, but I took a look myself. It appears that CDVWKWebViewEngine+CodePush.m assumes that Ionic is being used. THIS IS NOT THE CASE - I AM USING PURE CORDOVA. This method fiddles with the URL and changes it to "ionic://localhost", which is invalid in the pure Cordova case. If I comment out the code below, everything works for me.
- (id)loadPluginRequest:(NSURLRequest *)request {
// if (request.URL.fileURL) {
// NSDictionary* settings = self.commandDelegate.settings;
// NSString *bind = [settings cordovaSettingForKey:@"Hostname"];
// if(bind == nil){
// bind = @"localhost";
// }
// NSString *scheme = [settings cordovaSettingForKey:@"iosScheme"];
// if(scheme == nil || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"file"]){
// scheme = @"ionic";
// }
// NSString *CDV_LOCAL_SERVER = [NSString stringWithFormat:@"%@://%@", scheme, bind];
//
// NSURL* startURL = [NSURL URLWithString:((CDVViewController *)self.viewController).startPage];
// NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]];
// NSURL *url = [[NSURL URLWithString:CDV_LOCAL_SERVER] URLByAppendingPathComponent:request.URL.path];
// if ([request.URL.path isEqualToString:startFilePath]) {
// url = [NSURL URLWithString:CDV_LOCAL_SERVER];
// }
// if(request.URL.query) {
// url = [NSURL URLWithString:[@"?" stringByAppendingString:request.URL.query] relativeToURL:url];
// }
// if(request.URL.fragment) {
// url = [NSURL URLWithString:[@"#" stringByAppendingString:request.URL.fragment] relativeToURL:url];
// }
// request = [NSURLRequest requestWithURL:url];
// }
return [(WKWebView*)self.engineWebView loadRequest:request];
}
Thanks for your attention on this issue.
Hi all,
If you still have issues could you please provide some demo app with reproducing issue and reprosteps? Unfortunately, we can't reproduce any issues with it.
Hi,
Unfortunately, I am not permitted to share my app here for commercial reasons.
Reproducing should be fairly simple though. Just create a standard Cordova app that doesn't use ionic, then you should be able to easily reproduce the behaviour.
@Pigsnuck! Unfortunately, I couldn't. I use a sample in the codepush repo. It's more helpful for investigating if you will share pure project with codepush plugin and this issue.
@Krasavinigor I would be happy to create a pure Cordova project exhibiting the behaviour, but I am on vacation for the next 3 weeks. If you can keep this ticket open that long, I will create a project so you can replicate the error in development.
@Krasavinigor I wrote up how to test it using the sample apps in the codepush repo. The issue seems to be the custom url scheme
https://github.com/microsoft/cordova-plugin-code-push/issues/624#issuecomment-684513863
Thank @sithwarrior! I reproduced this issue. We will investigate it as soon as possible.
Hi Alexander,
1.13.1 did not fix the issue for me. The error message "Failed to load webpage with error: unsupported URL" now pops up as an alert instead of just in the XCode output.
I also tried updating the code-push dependency plugin from 3.0.1 to 4.0.2. The same error pops up when starting the app as before.
My Objective-C skills are very rusty, but I took a look myself. It appears that CDVWKWebViewEngine+CodePush.m assumes that Ionic is being used. THIS IS NOT THE CASE - I AM USING PURE CORDOVA. This method fiddles with the URL and changes it to "ionic://localhost", which is invalid in the pure Cordova case. If I comment out the code below, everything works for me.
- (id)loadPluginRequest:(NSURLRequest *)request { // if (request.URL.fileURL) { // NSDictionary* settings = self.commandDelegate.settings; // NSString *bind = [settings cordovaSettingForKey:@"Hostname"]; // if(bind == nil){ // bind = @"localhost"; // } // NSString *scheme = [settings cordovaSettingForKey:@"iosScheme"]; // if(scheme == nil || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"file"]){ // scheme = @"ionic"; // } // NSString *CDV_LOCAL_SERVER = [NSString stringWithFormat:@"%@://%@", scheme, bind]; // // NSURL* startURL = [NSURL URLWithString:((CDVViewController *)self.viewController).startPage]; // NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]]; // NSURL *url = [[NSURL URLWithString:CDV_LOCAL_SERVER] URLByAppendingPathComponent:request.URL.path]; // if ([request.URL.path isEqualToString:startFilePath]) { // url = [NSURL URLWithString:CDV_LOCAL_SERVER]; // } // if(request.URL.query) { // url = [NSURL URLWithString:[@"?" stringByAppendingString:request.URL.query] relativeToURL:url]; // } // if(request.URL.fragment) { // url = [NSURL URLWithString:[@"#" stringByAppendingString:request.URL.fragment] relativeToURL:url]; // } // request = [NSURLRequest requestWithURL:url]; // } return [(WKWebView*)self.engineWebView loadRequest:request]; }
Thanks for your attention on this issue.
As per this user - commenting out this section does fix the issue. I'm on Cordova and not Ionic - and this was replacing the request with ionic://localhost.
@luke-lewandowski I created a fork with my "not really a fix" if you're interested. My Cordova app is working in production with the forked code.
Thank @sithwarrior! I reproduced this issue. We will investigate it as soon as possible.
Any update on this? We would really like to push an update for our app.
Any news? This is a critical bug that makes it impossible to push updates to an iOS device...
Earlier I was using this plugin with UIWebview and all was working fine.
Now I have added WKWebview to my app & it stopped working.
Here are the few messages I am getting if I update a new release to appcenter.
It stucks after the above messages and the app never gets updated. Any quick help would be appreciated. Thanks!