TheUnreal
TheUnreal

Reputation: 24472

Ionic 2 PWA: Linking to specific page

I want to let people share their own user profile in my app. Therefore, each profile needs to have his own link, for example: myweb.com/user1 Unfortunetly, there are no such links/routes in an ionic 2 app.

This leads to my question- How I can let users share their own profile URL so other people will be redirected right to the sender profile page? Is there any way to do this so it will work in desktop too with Ionic 2?

Upvotes: 2

Views: 901

Answers (2)

Kishan Bharda
Kishan Bharda

Reputation: 5690

You can set your app link using Custom URL scheme plugin. It will help you to create your app link, which can open from browser. For example if you type myApp:// in browser URL then navigate to that URL, it will open your app.

To do this install plugin as below :

ionic cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=myCoolApp

Where myCoolApp is the URL schema from which you can open your app.

For testing it is working or not type myCoolApp:// in any browser of your phone and go. If it will redirect to your app it is working, otherwise not working.

Upvotes: 0

larpo
larpo

Reputation: 1163

For info - This is resolved with the addition of support for deeplinking in Ionic 3. The CLI commands $ ionic g page user will now create a page with it's own page module and the ability to specify how the url should be formed using the @IonicPage decorator. In your case you would also add the user id as a param in the @IonicPage segment, for example:

@IonicPage({
  name: "user",
  segment: "user/:id"
})

You can then deeplink straight to the user's page with the url.

Upvotes: 1

Related Questions