add docs
This commit is contained in:
parent
20d414652b
commit
6b3deafca1
@ -41,7 +41,7 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
|
||||
| _-- Multiple Apps_ | ❌ | ❌ | ✅ | ✅ |
|
||||
| **Cloud Messaging (FCM)** | ✅ | ✅ | ✅ |**?**|
|
||||
| **Crash Reporting** | ✅ | ✅ | ✅ | ❌ |
|
||||
| **Dynamic Links** | ❌ | ❌ | ❌ | ❌ |
|
||||
| **Dynamic Links** | ❌ | ❌ | ✅ | ❌ |
|
||||
| **Firestore** | ❌ | ❌ | ✅ | ❌ |
|
||||
| **Invites** | ❌ | ❌ | ❌ | ❌ |
|
||||
| **Performance Monitoring** | ✅ | ✅ | ✅ | ❌ |
|
||||
|
@ -54,6 +54,7 @@ dependencies {
|
||||
compile "com.google.firebase:firebase-crash:11.4.2"
|
||||
compile "com.google.firebase:firebase-database:11.4.2"
|
||||
compile "com.google.firebase:firebase-firestore:11.4.2"
|
||||
compile "com.google.firebase:firebase-invites:11.4.2"
|
||||
compile "com.google.firebase:firebase-messaging:11.4.2"
|
||||
compile "com.google.firebase:firebase-perf:11.4.2"
|
||||
compile "com.google.firebase:firebase-storage:11.4.2"
|
||||
@ -98,6 +99,7 @@ import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage; // Firebase R
|
||||
import io.invertase.firebase.crash.RNFirebaseCrashPackage; // Firebase Crash Reporting
|
||||
import io.invertase.firebase.database.RNFirebaseDatabasePackage; // Firebase Realtime Database
|
||||
import io.invertase.firebase.firestore.RNFirebaseFirestorePackage; // Firebase Firestore
|
||||
import io.invertase.firebase.links.RNFirebaseLinksPackage; // Firebase Links
|
||||
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // Firebase Cloud Messaging
|
||||
import io.invertase.firebase.perf.RNFirebasePerformancePackage; // Firebase Performance
|
||||
import io.invertase.firebase.storage.RNFirebaseStoragePackage; // Firebase Storage
|
||||
@ -118,6 +120,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
new RNFirebaseCrashPackage(),
|
||||
new RNFirebaseDatabasePackage(),
|
||||
new RNFirebaseFirestorePackage(),
|
||||
new RNFirebaseLinksPackage(),
|
||||
new RNFirebaseMessagingPackage(),
|
||||
new RNFirebasePerformancePackage(),
|
||||
new RNFirebaseStoragePackage()
|
||||
@ -207,3 +210,20 @@ dependencies {
|
||||
compile "com.google.firebase:firebase-perf:11.4.2"
|
||||
}
|
||||
```
|
||||
|
||||
## 5) Dynamic Links (optional)
|
||||
|
||||
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:
|
||||
|
||||
```xml
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:host="yoursite.example.com" android:scheme="http"/>
|
||||
<data android:host="yoursite.example.com" android:scheme="https"/>
|
||||
</intent-filter>
|
||||
```
|
||||
|
@ -177,3 +177,68 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||
If you're having problems with messages not being received, check out the following blog post for help:
|
||||
|
||||
https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.html
|
||||
|
||||
|
||||
|
||||
## 4) Dynamic Links (optional)
|
||||
|
||||
If you plan on using [Firebase Dynamic Links](https://firebase.google.com/docs/dynamic-links/) then, you need to:
|
||||
|
||||
### 4.1) 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.
|
||||
|
||||
### 4.2) 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.
|
||||
|
||||
### 4.3) Update `AppDelegate.m`
|
||||
|
||||
Add the following import:
|
||||
|
||||
`#import "RNFirebaseLinks.h"`
|
||||
|
||||
Add the following to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method before `[FIRApp Configure]`:
|
||||
|
||||
`[FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;`
|
||||
where `CUSTOM_URL_SCHEME` is the custom URL scheme you defined in your Xcode project.
|
||||
|
||||
In the application:openURL:sourceApplication:annotation: (for iOS 8 and older) add the following:
|
||||
|
||||
```objectivec
|
||||
- (BOOL)application:(UIApplication *)app
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary<NSString *, id> *)options {
|
||||
return [RNFirebaseLinks application:application
|
||||
openURL:url
|
||||
options:options];
|
||||
}
|
||||
```
|
||||
|
||||
In the application:openURL:options: (for iOS 9) add the following:
|
||||
|
||||
```objectivec
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation {
|
||||
return [RNFirebaseLinks application:application
|
||||
openURL:url
|
||||
sourceApplication:sourceApplication
|
||||
annotation:annotation];
|
||||
}
|
||||
```
|
||||
|
||||
In the application:continueUserActivity:restorationHandler (Universal Links on iOS 9 and newer) add the following:
|
||||
|
||||
```objectivec
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
continueUserActivity:(NSUserActivity *)userActivity
|
||||
restorationHandler:(void (^)(NSArray *))restorationHandler {
|
||||
return [RNFirebaseLinks application:application
|
||||
continueUserActivity:userActivity
|
||||
restorationHandler:restorationHandler];
|
||||
}
|
||||
```
|
||||
|
124
docs/modules/links.md
Normal file
124
docs/modules/links.md
Normal file
@ -0,0 +1,124 @@
|
||||
# Dynamic Links
|
||||
|
||||
[Firebase Dynamic Links](https://firebase.google.com/docs/dynamic-links/) allows you to create and receive links on both Android and iOS platforms. Assuming the installation instructions have been followed, Firebase Dynamic Links is ready to go.
|
||||
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
### Methods
|
||||
|
||||
#### `createDynamicLink(parameters: Object): Promise<String>`
|
||||
|
||||
Creates a long dynamic link.
|
||||
|
||||
```javascript
|
||||
firebase.links().createDynamicLink({
|
||||
dynamicLinkInfo: {
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com/",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
}
|
||||
}).
|
||||
then((url) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
#### `createShortDynamicLink(parameters: Object): Promise<String>`
|
||||
|
||||
Creates a short dynamic link.
|
||||
|
||||
```javascript
|
||||
firebase.links().createShortDynamicLink(dynamicLinkInfo: {
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com/",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
}
|
||||
}).
|
||||
then((url) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
### Parameters
|
||||
|
||||
Only the following parameters are currently supported:
|
||||
|
||||
```javascript
|
||||
{
|
||||
dynamicLinkInfo: {
|
||||
dynamicLinkDomain: string,
|
||||
link: string,
|
||||
androidInfo: {
|
||||
androidPackageName: string,
|
||||
androidFallbackLink: string,
|
||||
androidMinPackageVersionCode: string,
|
||||
androidLink: string
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: string,
|
||||
iosFallbackLink: string,
|
||||
iosCustomScheme: string,
|
||||
iosIpadFallbackLink: string,
|
||||
iosIpadBundleId: string,
|
||||
iosAppStoreId: string
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle: string,
|
||||
socialDescription: string,
|
||||
socialImageLink: string
|
||||
}
|
||||
},
|
||||
suffix: {
|
||||
option: "SHORT" or "UNGUESSABLE"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For more information ([see reference](https://firebase.google.com/docs/reference/dynamic-links/link-shortener))
|
||||
|
||||
## Receive Dynamic Links
|
||||
|
||||
### Methods
|
||||
|
||||
#### `getInitialLink(): Promise<String>`
|
||||
|
||||
Call getInitialLink to access the URL that the app has been launched from.
|
||||
|
||||
```javascript
|
||||
firebase.links().getInitialLink().then((url) => {
|
||||
//...
|
||||
});
|
||||
```
|
||||
|
||||
#### `onLink(listener: Function): () => any`
|
||||
|
||||
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.
|
||||
When you want to unsubscribe, just call the method that returned at subscription.
|
||||
|
||||
```javascript
|
||||
// Subscribe
|
||||
const unsubscribe = firebase.links().onLink().then((url) => {
|
||||
//...
|
||||
});
|
||||
|
||||
// Unsubscribe
|
||||
unsubscribe();
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user