Search code examples
androidcordovaphonegap-pluginswebintents

cordova open app from url - application error


i am trying to open my cordova app from external link like http://www.myurl.com/mypage and when the app opens it throw an alert

Application error: the connection to the server was unsuccesful. (file:///android_asset/www/www.myurl.com/mypage)

i guess i need to handle the incoming url somehow, but this alert is coming right up. tried to use "webintent.onNewIntent" and "webintent.getUri" but without success.

here is my code:

config.xml:

<preference name="AndroidLaunchMode" value="singleTask"/>

android manifest file:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:host="www.myurl.com" android:scheme="http" />
</intent-filter>

index.html

 <script>
    document.addEventListener('deviceready', function () {

        window.plugins.webintent.getUri(function (url) {
            console.log("INTENT URL: " + url);
            //...
        }, function (error) {
            console.log(error);
        });

        window.plugins.webintent.onNewIntent(function (url) {
            console.log("INTENT onNewIntent: " + url);
        }, function (error) {
            console.log(error);
        });
    }, false);
</script>

what am i missing?


Solution

  • figured out the problem...

    i had another plugin LaunchMyApp interfering. removing it did the trick.