Salman Mohammed
Salman Mohammed

Reputation: 289

How to make an app open with a URL using Cordova?

I have an app written in HTML, CSS, JavaScript. I am using Cordova to build it for iOS, Android, Windows and BlackBerry.

How can I register the app for a custom url scheme such that when I type "myapp://" in the mobile browser, it will try to open my app. Can I make changes in the config.xml file such that Cordova registers that URL to my app? Example code would be much appreciated!

Upvotes: 1

Views: 3623

Answers (2)

Akinde-peters
Akinde-peters

Reputation: 1

Go to res/xml/config.xml

Its should look somewhat like this.

<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<feature name="Whitelist">
    <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
    <param name="onload" value="true" />
</feature>

You need to create an allow-intent child to handle your custom URL schemes.

Upvotes: 0

Eno
Eno

Reputation: 10850

You can use the Custom URL plugin. When you install, you can provide a name for your own protocol scheme. On those platforms that require it, it will add the appropriate config changes for you.

Upvotes: 2

Related Questions