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

Compatibility with [email protected] #635

Closed
wants to merge 4 commits into from
Closed

Conversation

szh
Copy link

@szh szh commented Jul 28, 2020

Fixes #611 and the final remaining issue in #624

I'm not experienced with Objective-C so please review my code carefully!

@ghost
Copy link

ghost commented Jul 28, 2020

CLA assistant check
All CLA requirements met.

@szh
Copy link
Author

szh commented Aug 5, 2020

Upon further testing, I've found the following worrying issue.
I see when I load the app that window.location is still a file:// url, not an app://localhost file as specified in the app's config.xml:

<preference name="scheme" value="app"/>
<preference name="hostname" value="localhost"/>

The window.origin is therefore null, which poses a problem for CORS. I configured my site to allow CORS for app://localhost but not for 'null'.
It seems like my fix only solves the issue of the content not loading, but doesn't modernize the plugin to use the new scheme that's used by Cordova with WKWebView, starting in cordova-ios v6.
So I tried using the code in 'loadPluginRequest' from 'CDVWKWebViewEngine+CodePush.m' instead of from 'loadRequest' which is what I was using. That worked for the initial load but when trying to reload the page in JavaScript with location.reload() I get a blank white page with no errors.
Any help from the authors? I don't really understand all of the logic going on in these functions.

PS Is this plugin still being actively maintained by Microsoft? This is a serious issue - incompatibility with the latest cordova library - and so far it seems like it's been completely left up to the community.

@szh
Copy link
Author

szh commented Aug 6, 2020

So I tried using the code in 'loadPluginRequest' from 'CDVWKWebViewEngine+CodePush.m' instead of from 'loadRequest' which is what I was using. That worked for the initial load but when trying to reload the page in JavaScript with location.reload() I get a blank white page with no errors.

I just committed this change. Right now it seems the reload issue might've been from a missing <allow-navigation href="app://*"/> tag in my config.xml. Will follow up after more thorough testing.

@szh
Copy link
Author

szh commented Aug 17, 2020

I'm still running into issues with white screens. I've given this plugin everything I have (with my very limited Objective-C and iOS knowledge) but without some attention from the plugin authors this isn't a viable option for us and we're going to have to switch to another live update solution. Where is MS?

@alexandergoncharov-zz
Copy link
Contributor

Hi @szh ,
Thanks for contributing and sorry for the delay!

Unfortunately, I can't reproduce this compatibility issue. Could you please provide some demo app with reproducing issue and reprosteps?
I used latest versions of Cordova and cordova-ios.

@bterres
Copy link

bterres commented Aug 26, 2020

@szh is correct. This plugin does not work with the latest cordova-ios (6+). Cordova-ios 6+ has integrated the wkWebview engine functionality, making cordova-plugin-wkwebview-engine obsolete.

Specifically, Codepush will not work when a custom scheme and hostname is specified. The custom scheme is required for doing CORS requests on wkWebview. Code Push DOES work with the file:// protocol, so a basic Cordova project will work with this plugin, but not one that requires hitting an external api.

To reproduce:

  1. Create a new cordova project.
  2. Add cordova-plugin-code-push
  3. Create a Codepush project, add the deployment key to config.xml, and add codePush.sync() to onDeviceReady in www/js/index.js
  4. Add custom scheme and hostname to config.xml as @szh mentioned
    <preference name="scheme" value="app"/>
    <preference name="hostname" value="localhost"/>
  1. Build the cordova project and create a Codepush release

Codepush updates will get as far as installation, but the redirect to the new release code will fail, resulting in a white screen.

@mark-divitt
Copy link

Any updates on this issue? WKWebView is now required by Apple/iOS and Apple has released iOS 14. CodePush (for Cordova) is effectively broken in iOS as a result. Sure seems to me like this should be a very high priority for the CodePush team that supports Cordova. I see no evidence of active work on this issue...

@ruslan-bikkinin
Copy link
Contributor

Hi @szh @bterres @mark-divitt and thanks a lot for your effort on desire to fix this! Unfortunately, this PR doesn't cover all cases that may lead to the problems w/ cordova-ios 6 so I've prepared ultimate fix #655 that should be fixing all found problems. Please feel free to review it there. I'm closing this for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS codeSync rollback after relaunch app
5 participants