url-to-deep-link
v1.0.7
Published
Transform URLs to Deep Links and open your users apps
Downloads
856
Readme
url-to-deep-link
Transform URLs to Deep Links and open your users apps
Why ?
Deep links are a very powerful feature of Android and iOS devices that allows creators to point their users to the content with the best experience possible.
Looking for a way to redirect users throught a basic <a>
html link tag, I found out that no library does the conversion from a URL to a deep link. There was an attempt 4 years ago that wasn't still what I was looking for and another one more recent but that works using a Node server and still doesn't exactly do what I was looking for: just transform URLs to deep links.
Following on with the research some services like Branch.io and Url Geni exist but they are premium. Branch is hard to try because you need to request a demo, which I asked for but I haven't got any answer back yet. On the other hand Url Geni gives you a quick way to see it working in their home page and later on with a subscription you are able to generate URLs dinamically using their API.
Since universal links are still not a standard nor all the apps support them nor all version of Android and iOS support them, I decided to create this library.
url-to-deep-link
is a simple hardcoded solutions that translates URLs to their deep link version in order to open your users apps.
Install
npm install --save url-to-deep-link
Usage
// ES5 require syntax also works
// var getAndroidDeepLink = require("url-to-deep-link").getAndroidDeepLink;
import { getAndroidDeepLink, getIOSDeepLink } from "url-to-deep-link";
const yourAndroidDeepLink = getAndroindDeepLink("YOUR URL");
const yourIOSDeepLink = getIOSDeepLink("YOUR URL");
At this moment the following transformations are available (any other option will return undefined
):
- Page:
https://www.facebook.com/YOUR_PAGE_ID
You can get your id here.
Profile:
https://www.instagram.com/YOUR_USERNAME
Post (ONLY ANDROID):
https://www.instagram.com/p/YOUR_POST_ID
Profile:
https://www.twitter.com/YOUR_USERNAME
Tweet:
https://twitter.com/YOUR_USERNAME/status/YOUR_TWEET_ID
Notes
Facebook URL transformation by page name instead of ID and Instagram's post URL on iOS are not suported because they require an asynchronous call in order to get the ID of the page/post. In ./lib/apps/facebook.js
you can find an async version commented working fine although Facebook apps are currently a mess and there is no way to get an API access token.
Test
npm run test
Build (webpack)
npm run build
License
MIT