Giter VIP home page Giter VIP logo

Comments (8)

nikDemyankov avatar nikDemyankov commented on July 18, 2024

Maybe Cordova didn't actually update the plugin? Try to run:

cordova clean
cordova prepare
cordova build

Or reinstall the plugin.

Just created a new app:

cordova create TestApp
cd TestApp
cordova platform add android
cordova plugin add cordova-universal-links-plugin

Then added the following to the config.xml:

<universal-links>
    <host name="testapp.com">
        <path url="/test/*" />
    </host>
</universal-links>

And in index.js:

onDeviceReady: function() {
        app.receivedEvent('deviceready');
        universalLinks.subscribe(null, function() {
          alert('Launched by event');
        });
    },

Then cordova run android, close it and:

adb shell am start -W -a android.intent.action.VIEW -d "http://testapp.com/test/path" io.cordova.hellocordova

And I get the alert message.

from cordova-universal-links-plugin.

H0rst avatar H0rst commented on July 18, 2024

I can confirm, that it works with a new app. But not with the old one. I have removed the plugin and reinstalled it. I checked the files in platforms\android\src\com\nordnetab\cordova\ul. They are all new.

from cordova-universal-links-plugin.

nikDemyankov avatar nikDemyankov commented on July 18, 2024

Can you share your <universal-links> content from config.xml? Or something similar to what you have in it.

from cordova-universal-links-plugin.

H0rst avatar H0rst commented on July 18, 2024

I have added some debugging code to UniversalLinksPlugin.java:

    private void tryToConsumeEvent() {
Log.d("UniversalLinks", "tryToConsumeEvent");
        if (subscribers.size() == 0 || storedMessage == null) {
Log.d("UniversalLinks", "return");
            return;
        }
Log.d("UniversalLinks", "consume");

        final String storedEventName = storedMessage.getEventName();
Log.d("UniversalLinks", "storedEventName "+storedEventName);
        final Set<Map.Entry<String, CallbackContext>> subscribersSet = subscribers.entrySet();
        for (Map.Entry<String, CallbackContext> subscriber : subscribersSet) {
            final String eventName = subscriber.getKey();
Log.d("UniversalLinks", "eventName "+eventName);
            if (eventName.equals(storedEventName)) {
Log.d("UniversalLinks", "sendMessageToJs");
                sendMessageToJs(storedMessage, subscriber.getValue());
                storedMessage = null;
                break;
            }
        }
    }

When i try i get this output:

01-15 14:03:51.001: D/UniversalLinks(28299): tryToConsumeEvent
01-15 14:03:51.001: D/UniversalLinks(28299): consume
01-15 14:03:51.001: D/UniversalLinks(28299): storedEventName ULOpen
01-15 14:03:51.001: D/UniversalLinks(28299): eventName didLaunchAppFromLink

In config.xml i use

    <universal-links>
        <host name="www.blutdruckdaten.de" scheme="https">
            <path event="ULOpen" url="/lexikon.html" />
            <path event="ULOpen" url="/lexikon/*" />
            <path event="ULOpen" url="/chk*" />
            <path event="ULOpen" url="/del*" />
            <path event="ULOpen" url="/news.html" />
            <path event="ULOpen" url="/newsarchiv.html" />
            <path event="ULOpen" url="/news-en.html" />
            <path event="ULOpen" url="/newsarchive.html" />
        </host>
    </universal-links>

I have searched for didLaunchAppFromLink in your code and found it as default string. I have tried to replace it wth ULOpen, but i get the same result. I am not familiar with Java.

from cordova-universal-links-plugin.

H0rst avatar H0rst commented on July 18, 2024

I have replaced the text didLaunchAppFromLink in all your code with ULOpen. In this case it works.

from cordova-universal-links-plugin.

nikDemyankov avatar nikDemyankov commented on July 18, 2024

So, wait. If I understood correctly, you has a config.xml:

 <universal-links>
   <host name="www.blutdruckdaten.de" scheme="https">
    <path event="ULOpen" url="/lexikon.html" />
    <path event="ULOpen" url="/lexikon/*" />
    <path event="ULOpen" url="/chk*" />
    <path event="ULOpen" url="/del*" />
    <path event="ULOpen" url="/news.html" />
    <path event="ULOpen" url="/newsarchiv.html" />
    <path event="ULOpen" url="/news-en.html" />
    <path event="ULOpen" url="/newsarchive.html" />
  </host>
</universal-links>

Then in index.js you are trying to do like so:

  universalLinks.subscribe(null, function() {
    alert('alive')
  });

If so, then yes - that is not gonna work. If you have set event to the <path /> component - then you need to provide this event name, when you subscribe:

universalLinks.subscribe('ULOpen', function() {
    alert('alive')
  });

from cordova-universal-links-plugin.

H0rst avatar H0rst commented on July 18, 2024

X-) I missunderstood event name null is catching all events. I tried my event name before, but with the iOS problem i changed it to be sure, there is no error at this. Sorry.
You can close the issue, it is working now.

from cordova-universal-links-plugin.

nikDemyankov avatar nikDemyankov commented on July 18, 2024

I missunderstood event name null is catching all events.

No, it captures all unnamed events :) Good that the problem is solved.

from cordova-universal-links-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.