ionic-frameworksharesocialshare

Share my objects using a link - ionic3


I'm imagining this situation: I have my app opened on my device. I've just created a new element (object) in my app, for example a new Film like this

film = {
    title: 'Shark 3',
    subtitle: 'the revenge',
    date: '12-11-2019',
    plot: '...'
};

and I've saved it in my local storage. Now I want to share it on socials (WhatsApp, Facebook...) generating a link to this object. By clicking on this link I want my app (or the app store if it is not installed) to open. In case my app is installed, it should display a page with the film's information. Is it possible? How to do this in ionic?


Solution

  • The data you want to present is stored within the app and so available on every device your app is installed, I guess? Or is it data loaded from a backend?

    What you want to do is called a Deep Link. This means clicking on a links opens your app and redirects the user to a specific page depending on the link.

    This is possible with Ionic and the DeepLink native plugin.

    But there need to be done other things outside your app to make it work. You need to register and verify your domain with Google and/or Apple.

    And be aware testing this is very uncomfortable. It will only work with signed packes. So just running ionic cordova run android won't work, you will have to go the whole way creating a signed package as you need to do when you're going to publish it.

    Here is a Blog article describing the functionality.