This package provides a wrapper for Firebase Dynamic Links and View Dynamic Links Analytics Data REST APIs. It aims to define types for this APIs.
In order to use this package, you can read Short Link API and Analytics API full API documentations.
The Firebase Dynamic Links is available on npm as firebase-dynamic-links
:
$ npm install --save firebase-dynamic-links
Take note of your project Web Api Key
from setting page of the Firebase console.
Import the package and then create an instance of the FirebaseDynamicLinks
as follow:
import { FirebaseDynamicLinks } from 'firebase-dynamic-links';
const firebaseDynamicLinks = new FirebaseDynamicLinks(/* Web Api Key */);
const { shortLink, previewLink } = await firebaseDynamicLinks.createLink({
longDynamicLink: 'https://example.page.link/?link=https://www.example.com/&apn=com.example.android&ibi=com.example.ios',
});
const { shortLink, previewLink } = await firebaseDynamicLinks.createLink({
dynamicLinkInfo: {
domainUriPrefix: 'https://example.page.link',
link: 'https://www.example.com/',
androidInfo: {
androidPackageName: 'com.example.android',
},
iosInfo: {
iosBundleId: 'com.example.ios',
},
},
});
const { shortLink, previewLink } = await firebaseDynamicLinks.createLink({
longDynamicLink: 'https://example.page.link/?link=http://www.example.com/&apn=com.example.android&ibi=com.example.ios',
suffix: {
option: 'UNGUESSABLE',
},
});
const { linkEventStats } = await firebaseDynamicLinks.getLinkStats('https://example.page.link/wXYz', 7, accessToken);