-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: allow setting of hostname/startpage via code #3106
Comments
In Capacitor 3, we plan to allow multiple instances of Capacitor running within the native app. This should address your use case. You can track this here: #3182 |
Hi @dwieeb If I got it right, dynamic configuration is already on the roadmap for Capacitor v3 with #3141 ? I think that would be the nicer way for this exact use case, since it would allow a single web view as in "production". All we need is a hook that can be used to edit/generate the configuration before the web-views are loaded. What do you think? |
I'm not sure I understand. The intended usage would be that the native app manages Capacitor instances, so you could have one Capacitor instance for a particular hostname and another for a different one and switch between the instances at runtime. The Capacitor dynamic config generates a config object based on environment, so you could run |
Hi @dwieeb Regarding "dynamic configuration": So this is a pure CLI feature, that just rewrites a
Regarding "multiple instances": This sounds just very complex. Will there be a hook to allow configuration of the "primary" webview? I just need a single webView that can be configured before the first load. For my use case, it would be sufficient to have a hook that allows post-processing of the read capacitor.config.json... |
I do not understand why you need a hook in Java/Swift to configure the webview at runtime. Is dynamically generating the configuration file based on environment not enough? If so, why? |
Hi @dwieeb, thanks for your interest! We want to edit the configuration based on a user defined setting in the UserDefaults / UserSettings. The task is to enable our testers to install the app once and then change the environment the app uses in the user settings. On App start, this setting is picked up and used to boot the app. Therefore we need the possibility to change the configuration before the webView gets created/loads. For our use case, we only need to change the server.url. In production builds, we strip this functionality, i.e the settings bundle on iOS from the build. Pre-build generated capacitor config does not fit this use case, since then we had 5 different builds resulting in 5 different apps, which is far from optimal. |
Ahh! Thank you! This falls under another item the team has been discussing for Capacitor 3. I can't share everything right now because we haven't finalized our thoughts, but we are planning on improving configuration in the native runtimes and it will provide the option you need! I am going to make a note to update this issue when we can share our plan so you get a notification. Thanks for explaining! |
@imhoffd Hi! Capacitor 3 got released in May. Can you say which improved configuration for the native runtime you were talking about? I'm currently investigating how to set custom rewrite rules for the integrated web-server. Alternatively, can you point me to the documentation on how to run multiple servers in one app? Can those webviews communicate with each other, just like cross-origin |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Feature Request
Description
In Cordova, it was possible to set the hostname dynamically from code. This was used to allow testers and designers to verify, that a certain app build is compatible with all versions of the SPA deployed to different envs, without the need to build and install each env separately.
My use case is as follows:
Platform(s)
Preferred Solution
OPEN FOR SUGGESTIONS!
My idea but I'm not a swift dev:
CAPBridgeViewController.swift:
dynamicHostname
dynamicHostname
dynamicHostname
is set, use it to load the webView instead of the hostname from the settings/localAlternatives
Usage
Plugin authors can set the
dynamicHostname
in their Plugin's load() method:The text was updated successfully, but these errors were encountered: