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

Custom URL Scheme that has Dynamic URL Params #1227

Closed
ImranGholizadeh opened this issue Mar 24, 2022 · 2 comments
Closed

Custom URL Scheme that has Dynamic URL Params #1227

ImranGholizadeh opened this issue Mar 24, 2022 · 2 comments

Comments

@ImranGholizadeh
Copy link

I want to change the scheme and hostname in my app to a custom URL scheme that has dynamic url params. Because the URL params are dynamic (using vue.js router) the app needs to account for rendering specific UI and data based on the param.

For instance, I have a QR reader that redirects the user to a view that renders UI based on the URL param id..
So the QR reader redirects the user to a view such as https://xxxxxxxx.com/12345 where the param id is 12345.

In that case, how should I alter the code from my config.xml file below?

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

Building the app in Vue.js and using https://github.com/m0dch3n/vue-cli-plugin-cordova as a codova plugin.

@breautek
Copy link
Contributor

Schemes cannot be dynamic. Furthermore, Apple forbids any well-known protocol to be in schemes, including https.

For client-side routing, common practice is to use a hash-based strategy in cordova apps. Pretty url strategies are desirable for traditional websites as the URL is visible but they also require a web server to properly route all urls to the same base web application to handle reloads and such.

In cordova, there is no webserver, and the user cannot see the URL, so hash-based routing is generally a sufficient solution.

If your QR reader expects a https://... url, then I don't think it's going to work in a cordova environment.

So instead of using the domain name as your variables, you can use other parts of the URL as your variables, and have your application respond to URL changes via hashchange event & read/parses the URL.

Closing this because this doesn't appear to be a bug. You can ask our slack community for support style questions.

@NiklasMerz
Copy link
Member

NiklasMerz commented Mar 25, 2022

I once implemented a plugin to switch the scheme at runtime. It's very experimental and you have to be a bit careful to make it work properly but it can be useful in some cases. https://github.com/GEDYSIntraWare/cordova-plugin-webview-switch

But Norman is right you cannot use http or https.

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

No branches or pull requests

3 participants