Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

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

Closed
sephallen opened this issue Nov 19, 2015 · 16 comments
Closed

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

sephallen opened this issue Nov 19, 2015 · 16 comments

Comments

@sephallen
Copy link

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
Copy link
Member

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

@sephallen
Copy link
Author

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

I'm using Branch.io

@nikDemyankov
Copy link
Member

Try to change /SCnf to /SCnf/*:

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

@sephallen
Copy link
Author

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

@nikDemyankov
Copy link
Member

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

@nikDemyankov
Copy link
Member

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
Copy link
Author

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

@nikDemyankov
Copy link
Member

You're welcome )

@sephallen
Copy link
Author

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?

@sephallen sephallen reopened this Nov 26, 2015
@nikDemyankov
Copy link
Member

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

@sephallen
Copy link
Author

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

@nikDemyankov
Copy link
Member

I think this problem will go away as soon as I'll implement #18

@sephallen
Copy link
Author

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

@nikDemyankov
Copy link
Member

No problem) You're not the first one with that problem, and until #18 is done - not the last one...

@sephallen
Copy link
Author

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
Copy link
Member

Cool :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants