Deep linking in Ionic and how to handle custom URLs

Currently I catch the broadcast and depending on the url, switch state. This works fine but the problem Im currently having is with the back button. Im not using your example back button directive but I think we do some special stuff for the back button and I need to understand that more fully. Or is the state configuration supposed to take care of that? Thanks for responding.

The problem is if you start the app in a certain state where you expect to be able to go back. It won’t have any history to refer to which is why the back button doesn’t show by default. So the back button directive is there to workout if a fake back button should be displayed instead. I think this might be the cause of your problem, unless I"m misunderstanding.

What the directive does is check for state hierarchy. Denoted by the slashes in the state name. So if you have a slash in your state but there is no view history. Drop in this fake back button to move up a state by removing everything after the last slash. So if you’re doing anything special with the back button you might need to factor this part in as well.

There is probably a nicer way to hook into the ionic back button so you don’t need the directive, but I’ve not looked too far into it.

About that gist: trying to understand how to integrate something similar into our app. Looks like the extra lines you added at the top define a function that is also called right away that in turn defines module with a .run function that deals with adding the handlers, right? We already have a module with a ton of other stuff in it, so we would have to define a global app variable that the rest of the code in app.js can use outside of this one? Your gist also calls handleExternalOpenURL which isn’t defined there so Im not sure how that is supposed to look?

Sorry to be a pain! Just been struggling with finishing our custom url stuff for a couple days :frowning:

Still having trouble here. Are there any compatibility issues when use the Custom URL plugin alongside the WebIntent plugin? Im using your code but my global handleOpenURL() never fires. I was under the impression (maybe Im wrong) that since the WebIntent plugin is not using a custom URL and has a different action it should not be a problem to use it alongside the Custom URL plugin.

@maephet: All good, works now. Shall we use the cordova SDK now or the WEB SDK? Just implemented io.branchmetrics.branchreferral 0.4.9 “Branch”, do we have to change it again?

Ahh - no no. That’s our outdated one. Use the version that we co-mingled with the Web SDK. That way, you can use it on your site as well.

We’re going to retire the old Cordova one (io.branchmetrics.branchreferral) soon. We thought Cordova would have done it already as they’re migrating over to NPM.

I figured out the issue with the link to @chris08002’s gist link, here is the corrected link:

Hi. We have just implemented cordova sdk following docs ( Do we have to change it and integrate web sdk? If so, please provide a valid link, as the one you provided no longer works.


1 Like

No sir! Those are the correct docs. Please ignore the above. We’ve rewritten the Cordova lib and separated it out from our web SDK. Please leave any suggestions or issues you encounter on the Issues section of the repo.

Happy linking!

The Ionic deep linking plugin from Ionic is deprecated