From edc12487f5452b5d6dd0baddd37e7ffc5b4a509c Mon Sep 17 00:00:00 2001 From: Paul Huynh Date: Tue, 16 Jan 2018 22:34:26 +1100 Subject: [PATCH] Add Typescript definitions for Dynamic Links --- lib/index.d.ts | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/lib/index.d.ts b/lib/index.d.ts index 1eff94bf..204900da 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -64,6 +64,14 @@ declare module "react-native-firebase" { */ crash(): RNFirebase.crash.Crash; + /** + * Firebase Dynamic Links are links that work the way you want, on multiple + * platforms, and whether or not your app is already installed. + * See the official Firebase docs: + * https://firebase.google.com/docs/dynamic-links/ + */ + links(): RNFirebase.links.Links; + static fabric: { crashlytics(): RNFirebase.crashlytics.Crashlytics; }; @@ -895,5 +903,60 @@ declare module "react-native-firebase" { setUserIdentifier(userId: string): void; } } + + namespace links { + interface Links { + /** Creates a standard dynamic link. */ + createDynamicLink(parameters: LinkConfiguration): Promise; + /** Creates a short dynamic link. */ + createShortDynamicLink(parameters: LinkConfiguration): Promise; + /** + * Returns the URL that the app has been launched from. If the app was + * not launched from a URL the return value will be null. + */ + getInitialLink(): Promise; + /** + * Subscribe to URL open events while the app is still running. + * The listener is called from URL open events whilst the app is still + * running, use getInitialLink for URLs which cause the app to open + * from a previously closed / not running state. + * Returns an unsubscribe function, call the returned function to + * unsubscribe from all future events. + */ + onLink(listener: (url) => void): () => void; + } + + /** + * Configuration when creating a Dynamic Link (standard or short). For + * more information about each parameter, see the official Firebase docs: + * https://firebase.google.com/docs/reference/dynamic-links/link-shortener + */ + interface LinkConfiguration { + link: string, + dynamicLinkDomain: string, + androidInfo?: { + androidLink?: string, + androidPackageName: string, + androidFallbackLink?: string, + androidMinPackageVersionCode?: string, + }, + iosInfo?: { + iosBundleId: string, + iosAppStoreId?: string, + iosFallbackLink?: string, + iosCustomScheme?: string, + iosIpadBundleId?: string, + iosIpadFallbackLink?: string, + }, + socialMetaTagInfo?: { + socialTitle: string, + socialImageLink: string, + socialDescription: string, + }, + suffix?: { + option: 'SHORT' | 'UNGUESSABLE', + }, + } + } } }