How to configure deeplinks in AppModule.forRoot()?

@dzincolorado I get that your URLs would go inside /m.

My question was how/why would the Deeplinker pick up this APP_BASE_HREF and use it as a prefix for your URLs, as I didn’t see any config option about this in the Deeplinker docs or code.

Anyway, if you host the app at /m it should work anyway, as the Deeplinker only updates the fragment after /#/, which would always load /m/index.html internally.

@FdezRomero, good call. Prepending ‘/m’ to the route fixes the issue. Thanks very much!

I spoke to soon. It’s apparently not working. I had forgotten about some code that was explicitly setting the url to get around this issue. So, it looks like this may not work with PathLocationStrategy, then? I will keep digging. Thanks!

Denis

Where do APP_BASE_HREF and PathLocationStrategy come from? The Angular 2 router?

@FdezRomero, Yes, from @angular/router. So, I switched gears and managed to get @angular/router working instead of using DeepLinker, and so far it’s working. If I can get it working with all my segments, I’ll come back to update this thread with working code, if you and anyone else is interested.

Thanks for all your help so far.

Denis

1 Like

That’s the problem, the Deeplink does not use the Angular 2 router. Stop trying to make it work with/as the router. They are two separate things guys!

I have set this up using guidance from @FdezRomero above, but (becasue I am using this for an explicit internal routing issue) I would like to ‘pop’ a page from the stack before the deeplinker pushes the next one on top, is it possible to do? I cannot find documentation on the deeplinkConfig param, and have tried to make changes to deep-linker.ts in ionic docs but only have the transpiled version available in my app.

I haven’t seen anything like you mention in the code either. Is that something that you would be able to implement with a Nav Guard? I’m thinking maybe you can remove the previous page after the pop, so the history would fit what you want…

Yes actually I think that is something which a nav guard could take care of, I didn’t realise the NavController docs were so extensive.

We opened a another new thread with an example, hoping that someone from the team can help us on PWA, deeplinker and so on. :expressionless:

Yeah, that was my original question but no response from the Ionic team other than what there’s now in the docs. We are still missing the piece on how to make the Deeplinker and the Ionic Deeplinks plugin to work together (and hopefully not having 2 configuration objects with basically the same). And if it hasn’t been implemented yet, at least we’d like to know what’s the strategy so we can plan with that in mind…

Like FdezRomerom, I’m also interested in how to make the Deeplinker and the Ionic Deeplinks plugin to work together. So both web app and native apps support deep linking.

I have the DeepLinker working for web version (PWA) of my app and was hoping there is a simple solution to reuse the config with the native version of my app using Ionic DeepLink plugin or something similar. I’m planning on launching in the apps stores and offering a PWA too.

Anyone from Ionic able to provide some guidance on how to best achieve this?

Do we have to manually implement the logic as per Ionic Deeplink Plugin documentation (https://github.com/driftyco/ionic-plugin-deeplinks) in addition to DeepLinker code?

That’s what I’m doing now, it’s repetitive but it works. I read from commits/notes a while back that some configuration will be automatic (I don’t remember which, I suppose the plugin will grab the Deeplinker config).

Maybe @jgw9617 or @mhartington can give us a heads up on the whole Deeplinks status and the plans for it.

Hi @dzincolorado, can you share more infos about how you implemented angular/router? Can you share some code or something else?

@mburger81 here is his response to me in another thread

I have read and re-read this page and others about the Deeplinker, but I still don’t get it. I have it working to the point that it generates URLs in the location bar, but typing those same URLs in manually results in a 404. It isn’t clear from what I’ve read if that is somehow the desired behavior or not.

The use case is simple: when a user enters a URL path manually in the location bar in a web browser, can Ionic 2 support going to that page? If so, what is the mechanism that supports that? If not, it should be stated clearly that it is not possible. The philosophy behind things, vis-a-vis browser vs mobile, may be interesting, but first one needs to understand what is actually supported and possible with the framework. I have spent hours reading and an am unable to tell. Questions in the forum go unanswered.

Are you using the Hash strategy or path? Hash is the only one that works with ionic serve right now.

Thanks! I have tried both, but I will focus on the hash for now.

Using the hash strategy I don’t get the 404. Nothing happens: the page does not change.

How have you configured the deeplinker? Can you please post code?