From 9758c99537380841016748830653707f3a0f3b3f Mon Sep 17 00:00:00 2001 From: Omer Levy Date: Sun, 8 Oct 2017 18:43:59 +0300 Subject: [PATCH] [docs] dynamic links docs fixes --- docs/_sidebar.md | 1 + docs/installation-android.md | 4 +++- docs/installation-ios.md | 10 +++++++--- docs/modules/links.md | 10 +++++----- lib/modules/links/index.js | 14 ++++++++++++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 00df99b3..9e2abeb6 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -26,6 +26,7 @@ - [Crash Reporting](/modules/crash) - [Database](/modules/database) - [Firestore (Beta)](/modules/firestore) + - [Dynamic Links](/modules/links) - [Remote Config](/modules/config) - [Storage](/modules/storage) - [Transactions](/modules/transactions) diff --git a/docs/installation-android.md b/docs/installation-android.md index 59eb8600..be81bbc3 100644 --- a/docs/installation-android.md +++ b/docs/installation-android.md @@ -215,7 +215,9 @@ dependencies { If you plan on using [Firebase Dynamic Links](https://firebase.google.com/docs/dynamic-links/): -In `android/app/src/main/AndroidManifest.xml`, add a new intent filter to the activity that handles deep links for your app, and specify the host and the scheme: +Make sure to setup dynamic links for Android as described [here](https://firebase.google.com/docs/dynamic-links/android/receive#set-up-firebase-and-the-dynamic-links-sdk) + +In `android/app/src/main/AndroidManifest.xml`, add a new intent filter to the activity that handles deep links for your app (for react-native this is usually MainActivity), and specify the host and the scheme: ```xml diff --git a/docs/installation-ios.md b/docs/installation-ios.md index 4f6ba9cf..a42b1c30 100644 --- a/docs/installation-ios.md +++ b/docs/installation-ios.md @@ -166,17 +166,21 @@ https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.ht If you plan on using [Firebase Dynamic Links](https://firebase.google.com/docs/dynamic-links/) then, you need to: -### 5.1) create a new URL type +### 5.1) Setup + +Make sure to setup dynamic links for iOS as described [here](https://firebase.google.com/docs/dynamic-links/ios/receive#set-up-firebase-and-the-dynamic-links-sdk) + +### 5.2) create a new URL type In the Info tab of your app's Xcode project, create a new URL type to be used for Dynamic Links. Set the Identifier field to a unique value and the URL scheme field to either your bundle identifier or a unique value. -### 5.2) Enable Associated Domains capability +### 5.3) Enable Associated Domains capability In the Capabilities tab of your app's Xcode project, enable Associated Domains and add the following to the Associated Domains list: `applinks:app_code.app.goo.gl` where `app_code` is your dynamic links domain application code. -### 5.3) Update `AppDelegate.m` +### 5.4) Update `AppDelegate.m` Add the following import: diff --git a/docs/modules/links.md b/docs/modules/links.md index 15615aaf..a7af1813 100644 --- a/docs/modules/links.md +++ b/docs/modules/links.md @@ -7,7 +7,7 @@ All Dynamic Links operations are accessed via `firebase.links()` ## Create Dynamic Links -RNFirebase mimics [The REST API](https://firebase.google.com/docs/dynamic-links/rest) for Dynamic Links creation. +RNFirebase mimics [Firebase's REST API](https://firebase.google.com/docs/dynamic-links/rest) for Dynamic Links creation. The differences from the REST API are: 1. The input for the methods is a javascript object instead of a JSON object. 2. The response contains the URL string only. @@ -22,7 +22,7 @@ Creates a long dynamic link. firebase.links().createDynamicLink({ dynamicLinkInfo: { dynamicLinkDomain: "abc123.app.goo.gl", - link: "https://example.com/", + link: "https://example.com?param1=foo¶m2=bar", androidInfo: { androidPackageName: "com.example.android" }, @@ -43,7 +43,7 @@ Creates a short dynamic link. ```javascript firebase.links().createShortDynamicLink(dynamicLinkInfo: { dynamicLinkDomain: "abc123.app.goo.gl", - link: "https://example.com/", + link: "https://example.com?param1=foo¶m2=bar", androidInfo: { androidPackageName: "com.example.android" }, @@ -108,7 +108,7 @@ firebase.links().getInitialLink().then((url) => { }); ``` -#### `onLink(listener: Function): () => any` +#### `onLink(listener: Function): Function` On a new URL, the payload URL is passed to the listener callback. This method is only triggered when the app is running. Use getInitialLink for URLs which cause the app to open. In order to subscribe to the listener, call to the method with a callback and save the returned function. @@ -116,7 +116,7 @@ When you want to unsubscribe, just call the function that returned at subscripti ```javascript // Subscribe -const unsubscribe = firebase.links().onLink().then((url) => { +const unsubscribe = firebase.links().onLink((url) => { //... }); diff --git a/lib/modules/links/index.js b/lib/modules/links/index.js index 26832171..c4c94440 100644 --- a/lib/modules/links/index.js +++ b/lib/modules/links/index.js @@ -21,7 +21,7 @@ export default class Links extends ModuleBase { /** * Returns the link that triggered application open - * @returns {*} + * @returns {Promise.} */ getInitialLink() { return this._native.getInitialLink(); @@ -30,17 +30,27 @@ export default class Links extends ModuleBase { /** * Subscribe to dynamic links * @param listener - * @returns {*} + * @returns {Function} */ onLink(listener: Function): () => any { const rnListener = this._eventEmitter.addListener(EVENT_TYPE.Link, listener); return () => rnListener.remove(); } + /** + * Create long Dynamic Link from parameters + * @param parameters + * @returns {Promise.} + */ createDynamicLink(parameters: Object = {}): Promise { return this._native.createDynamicLink(parameters); } + /** + * Create short Dynamic Link from parameters + * @param parameters + * @returns {Promise.} + */ createShortDynamicLink(parameters: Object = {}): Promise { return this._native.createShortDynamicLink(parameters); }