Assuming you have a URL scheme configured in your app, this actually doesn't require any additional code work to implement. Here would be the steps:
- Go to your app page on Facebook and edit the button.
- Under the iOS Settings section, open the dropdown menu and select App

- In the next section, enter a URI using your app's custom URI scheme and a fallback website URL to use if your app is not installed (perhaps a page on your website, or a link directly to the iTunes store page)

Note: using the custom URI scheme only works acceptably in this case because Facebook is providing fallback functionality for another destination when the app is not installed. In any other place, if you opened your app's URI scheme without it being installed, you would instead get an ugly 'address could not be found' error. Obviously this is bad for user experience, so if you want to do conditional linking like this anywhere else, you can use a tool like Branch.io (full disclosure: I'm on the team) to handle it.