Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Set WEBVIEW_SERVER_URL before injecting native-bridge #4748

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

WIStudent
Copy link
Contributor

According to the docs Capacitor.convertFileSrc should return an URL starting with http://localhost on android, but instead this part is missing and something like /_capacitor_file_/path/to/device/file is returned. convertFileSrc gets the host part from webviewServerUrl, which is set when native-bridge is loaded:

const webviewServerUrl =
typeof win.WEBVIEW_SERVER_URL === 'string' ? win.WEBVIEW_SERVER_URL : '';

Because of the injection order, win.WEBVIEW_SERVER_URL has not been set yet when this line is executed. This PR fixes that by injecting the part that sets WEBVIEW_SERVER_URL before native-bridge.

@WIStudent WIStudent changed the title Android: Set WEBVIEW_SERVER_URL before injecting native-bridge fix(android): Set WEBVIEW_SERVER_URL before injecting native-bridge Jun 21, 2021
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch and thanks for the PR!

Can you only change the getScriptString function and not all function params?

Since they are public it would be a breaking change if somebody is using them internally.

@WIStudent
Copy link
Contributor Author

Good point, I changed it.

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

@jcesarmobile jcesarmobile merged commit 5d6b179 into ionic-team:main Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants