nordnet / cordova-universal-links-plugin

[DEPRECATED] - Cordova plugin to support Universal/Deep Links for iOS/Android.
https://github.com/nordnet/cordova-universal-links-plugin/issues/160
MIT License
349 stars 530 forks source link

Event listener doesn't appear to fire on Ionic #15

Closed sephallen closed 8 years ago

sephallen commented 8 years ago

I'm have issues listening for the event on the Ionic platform. I am able to successfully launch the app on iOS and Android from the universal link, but I cannot obtain any of the parameters.

I have tried adding the event listener to various places, app.js in run and on ionicplatform ready, in a controller and in the index.html

Am I doing something wrong?

nikDemyankov commented 8 years ago

Can you show <universal-links> preferences in your config.xml file?

sephallen commented 8 years ago
<universal-links>
    <host name="bnc.lt" scheme="https">
        <path url="/SCnf" />
    </host>
</universal-links>

I'm using Branch.io

nikDemyankov commented 8 years ago

Try to change /SCnf to /SCnf/*:

<universal-links>
    <host name="bnc.lt" scheme="https">
        <path url="/SCnf/*" />
    </host>
</universal-links>
sephallen commented 8 years ago

That's how I had it before, but still the same result.

nikDemyankov commented 8 years ago

This is a correct setup for the config.xml. Will try to reproduce the issue and then will post the result.

nikDemyankov commented 8 years ago

I have created a test Ionic project, did the setup as described in the readme here and here. Basically, prepared it to work with the Branch.io.

My config.xml is looks like this:

<universal-links>
    <host name="bnc.lt" scheme="https">
        <path url="/a2Be/*" />
    </host>
</universal-links>

My app.js is like that:

// default for Ionic
angular.module('starter', ['ionic'])
  .run(function($ionicPlatform) {
    $ionicPlatform.ready(function() {
      if (window.cordova && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      }
      if (window.StatusBar) {
        StatusBar.styleDefault();
      }
    });
});

// here we are subscribing for the default UL event, since it's not explicitly defined in config.xml
document.addEventListener('ul_didLaunchAppFromLink', didLaunchAppFromLink, false);

// this function should be is executed when we will launch the app from the link
function didLaunchAppFromLink(event) {
    var urlData = event.detail;
    alert('Did launch!');
};

As you can see, I am subscribing for the event outside the angular.module(...).

Then I press on the link https://bnc.lt/a2Be/test - the app is opened, and the alert dialog is displayed. So in your case it should be the similar thing.

sephallen commented 8 years ago

Thank you very much!! and thanks for the great plugin.

nikDemyankov commented 8 years ago

You're welcome )

sephallen commented 8 years ago

Sorry to reopen this, your fix is working great on Android but unfortunately not on iOS. Like before, the app successfully launches, but the event is not fired. Do you have any more suggestions?

nikDemyankov commented 8 years ago

That's weird, because I actually tested this on iOS... But will check again.

sephallen commented 8 years ago

It looks like it may be the device I'm testing on, its being very inconsistent.

nikDemyankov commented 8 years ago

I think this problem will go away as soon as I'll implement https://github.com/nordnet/cordova-universal-links-plugin/issues/18

sephallen commented 8 years ago

Ah cool, thanks! Sorry to drag up this issue again.

nikDemyankov commented 8 years ago

No problem) You're not the first one with that problem, and until https://github.com/nordnet/cordova-universal-links-plugin/issues/18 is done - not the last one...

sephallen commented 8 years ago

Just a quick update, the problem I was experiencing on iOS can be fixed here:

http://stackoverflow.com/questions/32729489/how-can-i-reset-ios-9-universal-linking-settings

Nothing to do with your plugin!

Thanks again :)

nikDemyankov commented 8 years ago

Cool :)