-[Firebase iOS SDK Changelog](https://firebase.google.com/support/release-notes/ios)
-[Firebase Android SDK Changelog](https://firebase.google.com/support/release-notes/android)
+- [Firebase iOS SDK Changelog](https://firebase.google.com/support/release-notes/ios)
+- [Firebase Android SDK Changelog](https://firebase.google.com/support/release-notes/android)
+
+## 10.4.0 (2020, Feb 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/122?closed=1)
+
+> Make sure to run a `pod repo update` on your dev machine, because this version includes the latest Firebase iOS (and Android) SDKs.
+
+## 10.3.3 (2019, Dec 24)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/121?closed=1)
+
+
+## 10.3.2 (2019, Dec 11)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/120?closed=1)
+
+
+## 10.3.1 (2019, Dec 6)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/119?closed=1)
+
+
+## 10.3.0 (2019, Dec 2)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/118?closed=1)
+
+
+## 10.2.1 (2019, Nov 26)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/117?closed=1)
+
+
+## 10.2.0 (2019, Nov 18)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/116?closed=1)
+
+
+## 10.1.1 (2019, Oct 29)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/114?closed=1)
+
+
+## 10.1.0 (2019, Oct 18)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/113?closed=1)
+
+
+## 10.0.2 (2019, Oct 16)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/112?closed=1)
+
+
+## 10.0.1 (2019, Sep 30)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/111?closed=1)
+
+
+## 10.0.0 (2019, Sep 17)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/109?closed=1)
+
+> Make sure to run a `pod repo update` on your dev machine, because this version includes the latest Firebase iOS (and Android) SDKs.
+
+> This version requires a minimum version of NativeScript 5.2. For MLKit features on iOS it's recommended to use a minimum `tns-ios` version of 6.1.0, otherwise you may run into build issues.
+
+
+## 9.1.1 (2019, Aug 27)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/110?closed=1)
+
+
+## 9.1.0 (2019, Aug 19)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/104?closed=1)
+
+> Make sure to run a `pod repo update` on your dev machine, because this version includes the latest Firebase iOS (and Android) SDKs.
+
+
+## 9.0.4 (2019, July 22)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/108?closed=1)
+
+
+## 9.0.3 (2019, July 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/107?closed=1)
+
+
+## 9.0.2 (2019, July 9)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/106?closed=1)
+
+
+## 9.0.1 (2019, June 18)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/105?closed=1)
+
+
+## 9.0.0 (2019, June 18)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/103?closed=1)
+
+#### BREAKING CHANGES
+
+> `fetchProvidersForEmail` has been removed - use `fetchSignInMethodsForEmail` instead.
+
+> Firebase Invites has been removed - use Dynamic Links instead! Also see https://firebase.google.com/docs/invites/deprecation and https://firebase.google.com/docs/dynamic-links/use-cases/user-to-user
+
+> Firebase crash reporting has been removed from the SDKs. Use Crashlytics instead. This also means `firebase.sendCrashLog` is gone. Use `firebase.crashlytics.sendCrashLog()` instead.
+
+> If you're on NativeScript < 5.2 and target iOS, then it's recommended to stick with a plugin version < 9.0.0 because you _may_ run into incompatibilities with certain features.
+
+> Also, make sure to run a `pod repo update` on your dev machine, because this version includes the latest Firebase iOS SDKs.
+
+## 8.3.2 (2019, May 14)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/101?closed=1)
+
+
+## 8.3.1 (2019, May 7)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/102?closed=1)
+
+
+## 8.3.0 (2019, May 2)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/100?closed=1)
+
+
+## 8.2.1 (2019, April 17)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/99?closed=1)
+
+
+## 8.2.0 (2019, April 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/98?closed=1)
+
+> Note: The Firebase iOS SDK now requires Xcode 10.1 or later.
+
+> Also note that there's a little breaking change that's easy to fix: the `name` and `profileImageURL` properties of the login result object have new names: `displayName` and `photoURL` respectively.
+
+## 8.1.1 (2019, March 24)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/97?closed=1)
+
+
+## 8.1.0 (2019, March 24)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/96?closed=1)
+
+
+## 8.0.1 (2019, March 16)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/95?closed=1)
+
+
+## 8.0.0 (2019, February 26)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/94?closed=1)
+
+### BREAKING CHANGES
+- `getAuthToken` no longer returns a token (`string`), but an `GetAuthTokenResult` object which contains more data. See #1008.
+- For better alignment with the Web API, `changePassword` is now `updatePassword`, `resetPassword` is now `sendPasswordResetEmail`. See #1080.
+
+
+## 7.7.0 (2019, January 20)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/92?closed=1)
+
+
+## 7.6.1 (2019, January 8)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/91?closed=1)
+
+
+## 7.6.0 (2018, December 21)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/90?closed=1)
+
+
+## 7.5.1 (2018, December 15)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/89?closed=1)
+
+
+## 7.5.0 (2018, December 15)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/88?closed=1)
+
+
+## 7.4.6 (2018, December 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/87?closed=1)
+
+
+## 7.4.5 (2018, December 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/86?closed=1)
+
+
+## 7.4.4 (2018, December 8)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/85?closed=1)
+
+
+## 7.4.3 (2018, December 3)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/84?closed=1)
+
+
+## 7.4.2 (2018, November 16)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/83?closed=1)
+
+
+## 7.4.1 (2018, November 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/82?closed=1)
+
+
+## 7.4.0 (2018, November 9)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/81?closed=1)
+
+
+## 7.3.0 (2018, October 24)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/80?closed=1)
+
+
+## 7.2.0 (2018, October 19)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/79?closed=1)
+
+
+## 7.1.6 (2018, October 12)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/78?closed=1)
+
+
+## 7.1.5 (2018, October 10)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/77?closed=1)
+
+
+## 7.1.4 (2018, October 9)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/76?closed=1)
+
+
+## 7.1.3 (2018, October 8)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/75?closed=1)
+
+
+## 7.1.2 (2018, October 2)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/74?closed=1)
+
+
+## 7.1.1 (2018, September 30)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/73?closed=1)
+
+
+## 7.1.0 (2018, September 26)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/72?closed=1)
+
+
+## 7.0.1 (2018, September 21)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/71?closed=1)
+
+
+## 7.0.0 (2018, September 19)
+[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/70?closed=1)
+
## 6.8.1 (2018, September 14)
[Fixes & Enhancements](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/milestone/69?closed=1)
diff --git a/README.md b/README.md
index a898bb6f..1d41d78f 100755
--- a/README.md
+++ b/README.md
@@ -1,31 +1,33 @@
# NativeScript Firebase plugin
+

The specified file was not found on this website. Please check the URL for mistakes and try again.
+This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.
+
+ Open Hosting Documentation
+
+
+
+_AdMob currently supports these three types of Ads, as does this plugin_
+
## Enabling AdMob
-Since plugin version 3.10.0 you can use Firebase _AdMob_ features.
-_AdMob_ lets you show banners or interstitials (full screen ads) in your app so you can earn a little money.
+### Android
+> ⚠️ Important! Plugin version 7.4.0+ requires you to do this - or your app will crash on start-up! ⚠️
+
+Open your App_Resources/Android/AndroidManifest.xml file and add this `meta-data` line at [the right spot](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/3fe3f6b4b9d1b83b048b10472bec923f64e08c75/demo/app_resources/Android/src/main/AndroidManifest.xml#L28-L30) (and replace the value by the actual App ID of [your app](https://apps.admob.com/)!):
+
+```xml
+
## Enabling Analytics
-This plugin has had enalytics enabled since day 1 to collect usage and behavior data for your app. However, you were not able to push your own events. That changed with version 3.6.0 😃🔥
+This plugin has had enalytics enabled since day 1 to collect usage and behavior data for your app,
+and since version 3.6.0 you are able to push your own events.
-_Beware that your Analytics events in the Firebase console dashboards are updated periodically throughout the day, not real-time._
+With version 10.0.0 I've been able to make Analytics an optional dependency (because the upstream SDKs made it optional as well),
+so if you want to use Analytics then nothing needs to change (enabled by default), but if you don't, you can edit `firebase.nativescript.json`
+and add `"analytics": false`, then `rm -rf node_modules platforms`.
+_Beware that your Analytics events in the Firebase console dashboards are updated periodically throughout the day, not real-time._
## Functions
@@ -48,6 +52,41 @@ For a list of predefined Events [check this Android reference](https://firebase.
);
```
+### analytics.logComplexEvent
+Same thing as logEvent but you can add an `Array` or specific types (not just `string`).
+See `LogComplexEventTypeParameter` for all available types.
+
+```typescript
+import * as firebase from "nativescript-plugin-firebase";
+import { LogComplexEventTypeParameter } from "nativescript-plugin-firebase";
+
+firebase.analytics.logComplexEvent({
+ key: "view_item_list",
+ parameters: [{
+ key: "item1",
+ type: "array",
+ value: [
+ {
+ parameters: [
+ {key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
+ {key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING},
+ {key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE},
+ {key: "index", value: 1, type: LogComplexEventTypeParameter.INT}
+ ]
+ },
+ {
+ parameters: [
+ {key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
+ {key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING},
+ {key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE},
+ {key: "index", value: 2, type: LogComplexEventTypeParameter.INT}
+ ]
+ }
+ ]
+ }]
+});
+```
+
### analytics.setUserProperty
User properties are attributes you define to describe segments of your userbase, such as language preference or geographic location.
@@ -99,3 +138,10 @@ You can also pass this property during `init()`:
```
> If you want to disable collection without calling this function programmatically, then you can add a flag to your `App_Resources/iOS/Info.plist` and `App_Resources/Android/AndroidManifest.xml`, see [Firebase's documentation](https://firebase.google.com/support/guides/disable-analytics) for details.
+
+### analytics.setSessionTimeoutDuration
+Sets the duration of inactivity that terminates the current session. The default value is 1800 seconds (30 minutes).
+
+```js
+ firebase.analytics.setSessionTimeoutDuration(600); // 10 minutes
+```
diff --git a/docs/AUTHENTICATION.md b/docs/AUTHENTICATION.md
index 618b74ea..c6e08a70 100644
--- a/docs/AUTHENTICATION.md
+++ b/docs/AUTHENTICATION.md
@@ -1,7 +1,7 @@
## Enabling Authentication
-You can sign in a user either
+You can sign in a user, using either
* [anonymously](#anonymous-login),
* by [email and password](#email-password-login),
@@ -9,7 +9,8 @@ You can sign in a user either
* by [phone verification](#phone-verification),
* using a [custom token](#custom-login),
* using [Facebook](#facebook-login),
-* using [Google](#google-sign-in).
+* using [Google](#google-sign-in),
+* using [Apple](#sign-in-with-apple).
Each of these login mechanisms need to be enabled in your Firebase console at the 'Login & Auth' tab.
@@ -23,8 +24,8 @@ All login functions below, as well as `getCurrentUser` return a 'User' object wi
|`emailVerified`|no|You can send an email with a verification link which this refers to
|`providers`|no|An array of {id: value} objects, where value can be 'facebook.com', etc
|`email`|yes|Not all providers require an email address
-|`name`|yes|The name stored at the provider
-|`profileImageURL`|yes|A string containing a link to a user image on the web
+|`displayName`|yes|The name stored at the provider. Note that before plugin version 8.2.0 this was called `name`.
+|`photoURL`|yes|A string containing a link to a user image on the web. Note that before plugin version 8.2.0 this was called `profileImageURL`.
|`phoneNumber`|yes|The user's phone number
|`refreshToken`|yes|iOS only
|`additionalUserInfo`|no|See `AdditionalUserInfo` below
@@ -62,12 +63,13 @@ const firebaseWebApi = require("nativescript-plugin-firebase/app");
As stated [here](https://firebase.google.com/docs/auth/ios/manage-users#get_the_currently_signed-in_user):
> The recommended way to get the current user is by setting a listener on the Auth object
-
+
Then add the following lines to your code and check for setup instructions for your platform below.
@@ -523,7 +612,10 @@ Then add the following lines to your code and check for setup instructions for y
type: firebase.LoginType.GOOGLE,
// Optional
googleOptions: {
- hostedDomain: "mygsuitedomain.com"
+ hostedDomain: "mygsuitedomain.com",
+ // NOTE: no need to add 'profile' nor 'email', because they are always provided
+ // NOTE 2: requesting scopes means you may access those properties, but they are not automatically fetched by the plugin
+ scopes: ['https://www.googleapis.com/auth/user.birthday.read']
}
}).then(
function (result) {
@@ -548,9 +640,9 @@ Upon successful authentication, Google creates an access token that can be obtai
```
#### iOS
-If you didn't choose this feature during installation you can open the `Podfile` in the plugin's `platforms/ios` folder and uncomment the `GoogleSignIn` line.
+If you didn't choose `Firebase Authentication` and `Firebase Google Authentication` during installation you can remove the `platforms` and `node_modules` folders and the `firebase.nativescript.json` file, then run `npm i`. This will prompt your which Firebase features you'd like to enable.
-Make sure the URL Scheme for `REVERSED_CLIENT_ID` is in `app/App_Resources/iOS/Info.plist`:
+Make sure the URL Scheme for `REVERSED_CLIENT_ID` is in `app/App_Resources/iOS/Info.plist`. The value of `REVERSED_CLIENT_ID` can be found in your `App_Resources/iOS/GoogleService-Info.plist` :
```xml
+
+> Firebase Crash reporting has been deprecated since plugin version 5.3.0 and was removed in plugin version 9.0.0 - use Crashlytics instead.
+
+## Enabling Crashlytics
+You will be prompted during installation of the plugin to enable Crashlytics (off by default).
+This will add `"crashlytics": true` to your `firebase.nativescript.json` file, now remove the `platforms` folder so this change is picked up.
+
+## Enabling Opt-In Crashlytics Collection (GDPR, anyone?)
+Since plugin version 8.3.0 you can disable Crashlytics collection by default, and enabled it at runtime.
+
+Add [this](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/7418905a22661dfc3bf40d1a67a5e7254c89d54e/demo/app_resources/Android/src/main/AndroidManifest.xml#L32-L34) to your `AndroidManifest.xml`
+and [this](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/7418905a22661dfc3bf40d1a67a5e7254c89d54e/demo/app_resources/iOS/Info.plist#L109-L110) to your `Info.plist`, so it's disabled by default.
+
+You can then either pass `crashlyticsCollectionEnabled: true` in `firebase.init()`,
+or call `crashlytics.setCrashlyticsCollectionEnabled(true)` to enabled Crashlytics collection for the user.
+
+## Configuration in the Firebase Console
+When setting up Crashlytics, select "This app is new to Crashlytics" and press "Next".
+Then the screen changes to something like "waiting for your first crash report".
+Then produce a crash, and it can easily take a day before that screen changes (later data comes in much quicker).
+
+## Crashlytics API
+
+### `sendCrashLog`
+Send a native iOS or Android exception to Crashlytics.
+
+```typescript
+// for NativeScript 7, import like this:
+import { crashlytics } from "@nativescript/firebase/crashlytics";
+
+// for older versions of NativeScript, either import like this:
+import { crashlytics } from "nativescript-plugin-firebase"; // and do: crashlytics.sendCrashLog
+// or this:
+import { crashlytics as firebaseCrashlytics } from "nativescript-plugin-firebase"; // and do: firebaseCrashlytics.sendCrashLog
+// or this:
+import * as firebase from "nativescript-plugin-firebase"; // and do: firebase.crashlytics.sendCrashLog
+
+import { isAndroid, isIOS } from "tns-core-modules/platform";
+
+if (isAndroid) {
+ crashlytics.sendCrashLog(new java.lang.Exception("test Exception"));
+} else if (isIOS) {
+ crashlytics.sendCrashLog(new NSError({
+ domain: 'ShiploopHttpResponseErrorDomain',
+ code: 42,
+ userInfo: null
+ }));
+}
+```
+
+### `set*`
+Set a value that will be logged with an error and showing in the Firebase console on the 'Keys' tab of the error details.
+
+```typescript
+import { crashlytics } from "nativescript-plugin-firebase";
+
+crashlytics.setString("test_key", "test_value");
+crashlytics.setBool("test_key_bool", true);
+crashlytics.setInt("test_key_int", 2);
+crashlytics.setDouble("test_key_double", 56615.55548465);
+crashlytics.setFloat("test_key", 54646.45);
+
+crashlytics.setUserId("user#42");
+```
+
+### `log`
+Add a message that will be logged with an error and showing in the Firebase console on the 'Logs' tab of the error details.
+
+```typescript
+crashlytics.log("more log info...");
+```
+
+### `crash`
+For easier testing, version 8.2.0 exposed this `crash()` function of the native Firebase Crashlytics SDKs:
+
+```typescript
+import { crashlytics } from "nativescript-plugin-firebase";
+
+crashlytics.crash();
+```
+
+> This should crash your app unless you have `discardUncaughtJsExceptions` set to `true` in `app/package.json`.
\ No newline at end of file
diff --git a/docs/CRASHREPORTING.md b/docs/CRASHREPORTING.md
deleted file mode 100644
index 7a23512f..00000000
--- a/docs/CRASHREPORTING.md
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-## Enabling Crash Reporting / Crashlytics
-Since version 5.3.0 you can choose either Crashlytics (recommended) or the older Firebase Crash Reporting (which doesn't really work on iOS).
-You will be prompted during installation of the plugin to enable either Crashlytics or Crash Reporting (both are off by default).
-
-Note that if you want to use Crashlytics, make sure your `firebase.nativescript.json` file has `"crashlytics": true` and `"crash_reporting": false`,
-then remove the `platforms` folder so these changes are picked up.
diff --git a/docs/DATABASE.md b/docs/DATABASE.md
index 0fc707d1..4d48f62d 100644
--- a/docs/DATABASE.md
+++ b/docs/DATABASE.md
@@ -170,7 +170,8 @@ Let's say we have the structure as defined at `setValue`, then use this query to
if (!result.error) {
console.log("Event type: " + result.type);
console.log("Key: " + result.key);
- console.log("Value: " + JSON.stringify(result.value));
+ console.log("Value: " + JSON.stringify(result.value)); // a JSON object
+ console.log("Children: " + JSON.stringify(result.children)); // an array, added in plugin v 8.0.0
}
};
@@ -255,9 +256,12 @@ Removes values in multiple locations
```
### addChildEventListener
+
To listen for changes in your database you can pass in a listener callback function.
You get to control which path inside you database you want to listen to, by default it's `/` which is the entire database.
+If you have defined access rules that depend on authentication, add listeners after authentication, attempting to access data not authorized by the access rules will prevent your listener from working properly, even if you add them at first. listing some data as just added, which seems to be a bug in Firebase's access rules system.
+
The plugin will take care of serializing native data structures to JSON data.
```js
@@ -311,7 +315,8 @@ The link is for the iOS SDK, but it's the same for Android.
console.log("Listener error: " + result.error);
} else {
console.log("Key: " + result.key);
- console.log("Calue: " + JSON.stringify(result.val()));
+ console.log("key exists? " + result.exists());
+ console.log("Value: " + JSON.stringify(result.val()));
}
};
@@ -345,6 +350,42 @@ You can see an example of this (for both the native and web API) in the [demo ap
```
+
+> Note that the _Invites_ feature has been removed in plugin version 9.0.0, and will be removed from Firebase itself on January 24, 2020.
+
+## Enabling Dynamic Links
+
+You will be prompted during installation of the plugin to enable Dynamic Links (off by default).
+This will add `"dynamic_links": true` to your `firebase.nativescript.json` file, now remove the `platforms` folder so this change is picked up.
+
+### Android
+* If you want to use App Links, [make sure you've uploaded your SHA256 fingerprints](https://developers.google.com/android/guides/client-auth) to the Firebase console.
+
+### iOS
+* You must have the App Store ID and App ID set in your developer console [project settings](https://console.firebase.google.com/project/_/settings/general/).
+
+## Receiving Dynamic Links
+
+### Android
+To have a dynamic link open your app you need to add an Intent filter to the `
+
+> Added in plugin version 7.1.0, by [breningham](https://github.com/breningham)
+
+## Cloud Functions?
+Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests.
+Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
+
+[Learn more here..](https://firebase.google.com/docs/functions/)
+
+> Note that you don't need to enable this feature in the plugin unless you want to [call those Cloud Functions from your app](https://firebase.google.com/docs/functions/callable).
+
+## Enabling Cloud Functions
+To add this feature to your project, either:
+
+* Remove `firebase.nativescript.json` from the root of the project and run `npm i`, or
+* Edit that file and add `"functions": true`.
+
+In both cases, remove the `/platforms` folder afterwards so the required native library will be added upon the next build.
+
+
+## API
+You can use either the Web API syntax (easy for interoperability with a web version of your app), or our custom native syntax.
+Use whichever syntax you like most - the underlying implementation is the same.
+
+Both API supports Cloud Functions locations/regions as [described here](https://firebase.google.com/docs/functions/locations).
+To set a function's region, pass the region string as the second parameter of `httpsCallable`.
+If the region parameter is not supplied, the function will use Cloud Function's default region, which as of this doc is written is `us-central1`.
+
+### `httpsCallable`
+This example uses the Cloud Function as [implemented here](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/ff95c77c7b09acf66654f53c52e8ae0c8d7b1c78/demo/firebasefunctions/functions/src/index.ts#L15-L19).
+
+
-
-## Enabling Invites
-Since plugin version 3.12.0 you can use Firebase _Invites_ features.
-
-_Invites_ lets you invite other users to your app from right within your own app, via SMS and/or Email.
-
-Keep in mind that invites are based of dynamic links, and so calling for an invite may return a plain dynamic link, in which case invitationId is null.
-
-### Android
-* [Make sure you've uploaded your SHA1 and SHA256 fingerprints](https://developers.google.com/android/guides/client-auth) to the Firebase console.
-
-### iOS
-* On iOS the user must be signed in with their Google Account to send invitations.
-* You must have the App Store ID set in your developer console project in order for invitations to successfully be sent.
-* For more details see [https://firebase.google.com/docs/invites/ios](https://firebase.google.com/docs/invites/ios).
-
-#### Contacts Usage Permission
-Open `app/App_Resources/iOS/Info.plist` and add this somewhere in the file (if it's not already there):
-
-```xml
-
+
+> Added in plugin version 8.2.0
+
+## In-App Messaging?
+Engage active app users with contextual messages.
+
+[Learn more here..](https://firebase.google.com/docs/in-app-messaging/)
+
+## Want to see a demo?
+Check out the (code of the) [Vue demo](demo-vue)!
+
+## Enabling In-App Messaging
+To add this feature to your project, either:
+
+* Remove `firebase.nativescript.json` from the root of the project and run `npm i`, or
+* Edit that file and add `"in_app_messaging": true`.
+
+In both cases, remove the `/platforms` folder afterwards so the required native library will be added upon the next build.
+
+## API
+There's nothing you have to do code-wise if you only want to display messages.
+If you want to capture a 'button clicked' event however, read on.
+
+### `onMessageClicked`
+
+```typescript
+import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
+
+inappmessaging.onMessageClicked(message => {
+ console.log("Clicked a button for Campaign: " + message.campaignName);
+});
+```
+
+### `onMessageImpression`
+You can also get notified if a message is being shown to a user:
+
+```typescript
+import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
+
+inappmessaging.onMessageImpression(message => {
+ console.log("A message belonging to this campaign is being shown: " + message.campaignName);
+});
+```
+
+### `triggerEvent`
+Trigger in-app messages programmatically.
+
+Firebase In-App Messaging by default allows you to trigger in-app messages with Google Analytics for Firebase events, with no additional integration. You can also manually trigger events programmatically with the Firebase In-App Messaging SDK’s programmatic triggers.
+
+In the In-App Messaging campaign composer, create a new campaign or select an existing campaign, and in the Scheduling step of the composer workflow, note the event ID of a newly-created or existing messaging event. Once noted, instrument your app to trigger the event by its ID.
+
+```typescript
+import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
+
+const eventName = "myEvent";
+inappmessaging.triggerEvent(eventName);
+```
\ No newline at end of file
diff --git a/docs/MESSAGING.md b/docs/MESSAGING.md
index 2ca4c26c..487b1620 100644
--- a/docs/MESSAGING.md
+++ b/docs/MESSAGING.md
@@ -8,7 +8,17 @@ Although using push messages in your Firebase app is really easy setting it up i
If you didn't choose this feature during installation you can add `"messaging": true` to `
-> Note that if you don't want a badge on the app icon, remove the `badge` property or set it to 0. Note that launching the app clears the badge anyway.
+> Note that if you don't want a badge on the app icon, remove the `badge` property or set it to 0.
### Notfication-popup example
@@ -160,6 +208,8 @@ This results in a payload of:
- App in the foreground: `{"foo":"bar", "gcm.message_id":"0:1522952720644653%3194ccac3194ccac", "foreground":true, "title":"My title", "body":"My text"}`
- App in the background: `{"foo":"bar", "gcm.message_id":"0:1522952737879515%3194ccac3194ccac", "title":"My title", "body":"My text", "foreground":false}`
+Note that on iOS, when the notification was tapped, the payload will contain `notificationTapped: true`. That may help you with some logic in your app.
+
### (iOS) background notification example
> Take note of `content_available:true` here
@@ -176,13 +226,13 @@ This results in a payload of:
To register the app to receive interactive pushes you need to call `firebase.registerForInteractivePush(model)`.
And you may hook to the `model.onNotificationActionTakenCallback` callback to know what action the user took interacting with the notification.
-Each action has either type `button` or `input`, and you can set `options` to do any or all of:
+Each action has a type of either `button` or `input`, and you can set `options` to do any or all of:
- Launch the app: `foreground`.
- Only allow the action when the device is unlocked: `authenticationRequired`.
- Make the text red to indicate something will be removed/deleted/killed: `destructive`.
Consider this example, where an interactive push notification is received which the user expands and picks the fourth option.
-He then types his reply, and (because of how the action was configured) the app launches and captures the reply.
+They then type their reply, and (because of how the action was configured) the app launches and captures the reply.
@@ -262,7 +312,7 @@ The payload to trigger the notification in the screenshots above is:
}
```
-> *IMPORTANT* Use the `click_action` only for push notifications on iOS. When such a message is tapped in the Android notification center the app WON'T be opened. This will probably be fixed in the future.
+> *IMPORTANT* Use `click_action` only for push notifications on iOS. When such a message is tapped in the Android notification center the app WON'T be opened. This will probably be fixed in the future.
### (iOS) showing a notification while the app is in the foreground
Add the `showWhenInForeground` flag to your payload:
@@ -275,6 +325,15 @@ Add the `showWhenInForeground` flag to your payload:
}
```
+### (iOS) Disable automatic clearing the badge
+Currently by default, when launching the app, badge is cleared. You can disable the feature by passing a flag in your init option.
+
+```js
+firebase.init({
+ autoClearBadge: false
+});
+```
+
## What if iOS doesn't show/receive notifications in the background?
Make sure you [`require` the plugin in `app.ts` / `main.ts` / `main.aot.ts`](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/55cfb4f69cf8939f9101712fed22383196b08d36/demo/app/app.ts#L5)
*before* `application.start()`, and do `init()` *after* the app has started (not in `app.ts` - not even in a timeout; move it out of `app.ts` entirely!).
diff --git a/docs/ML_KIT.md b/docs/ML_KIT.md
index daa0037c..02bfc2b6 100644
--- a/docs/ML_KIT.md
+++ b/docs/ML_KIT.md
@@ -2,6 +2,8 @@
Make sure to check out [this demo app](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/tree/master/demo-ng) because it has almost all ML Kit features this plugin currently supports! Steps:
+> Supported on Android, and iOS 10+
+
```bash
git clone https://github.com/EddyVerbruggen/nativescript-plugin-firebase
cd nativescript-plugin-firebase/src
@@ -32,6 +34,11 @@ and add this somewhere in the file (if it's not already there):
@@ -90,6 +100,8 @@ To be able to use Cloud features you need to do two things:
#### Still image (on-device)
+##### TypeScript
+
```typescript
import { MLKitRecognizeTextResult } from "nativescript-plugin-firebase/mlkit/textrecognition";
const firebase = require("nativescript-plugin-firebase");
@@ -101,8 +113,22 @@ firebase.mlkit.textrecognition.recognizeTextOnDevice({
}).catch(errorMessage => console.log("ML Kit error: " + errorMessage));
```
+##### JavaScript
+
+```js
+var firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.textrecognition.recognizeTextOnDevice({
+ image: imageSource // a NativeScript Image or ImageSource, see the demo for examples
+}).then(function(result) {
+ console.log(result.text ? result.text : "");
+}).catch(function (errorMessage) { return console.log("ML Kit error: " + errorMessage); });
+```
+
#### Still image (cloud)
+##### TypeScript
+
```typescript
import { MLKitRecognizeTextResult } from "nativescript-plugin-firebase/mlkit/textrecognition";
const firebase = require("nativescript-plugin-firebase");
@@ -114,19 +140,35 @@ firebase.mlkit.textrecognition.recognizeTextCloud({
.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
```
+##### JavaScript
+
+```js
+var firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.textrecognition.recognizeTextCloud({
+ image: imageSource // a NativeScript Image or ImageSource, see the demo for examples
+}).then(function(result) {
+ console.log(result.text ? result.text : "");
+}).catch(function (errorMessage) { return console.log("ML Kit error: " + errorMessage); });
+```
+
#### Live camera feed
The exact details of using the live camera view depend on whether or not you're using Angular / Vue.
You can use any view-related property you like as we're extending `ContentView`.
So things like `class`, `row`, `width`, `horizontalAlignment`, `style` are all valid properties.
-Plugin-specific are the optional properties `processEveryNthFrame` and `torchOn`, and optional event `scanResult`.
-You can `processEveryNthFrame` set to a lower value than the default (5) to put less strain on the device.
+Plugin-specific are the optional properties `processEveryNthFrame`, `preferFrontCamera` (default `false`), `torchOn`, and `pause`, as well as the optional `scanResult` event.
+
+You can set `processEveryNthFrame` set to a lower value than the default (5) to put less strain on the device.
Especially 'Face detection' seems a bit more CPU intensive, but for 'Text recognition' the default is fine.
+If you don't destroy the scanner page/modal but instead briefly want to hide it (but keep it alive),
+you can pause the scanner with the `pause` property.
+
> Look at [the demo app](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/tree/master/demo-ng) to see how to wire up that `onTextRecognitionResult` function, and how to wire `torchOn` to a `Switch`.
-##### Angular / Vue
+##### Angular
Register a custom element like so in the component/module:
```typescript
@@ -142,11 +184,32 @@ Now you're able to use the registered element in the view:
width="260"
height="380"
processEveryNthFrame="10"
+ preferFrontCamera="false"
+ [pause]="pause"
[torchOn]="torchOn"
(scanResult)="onTextRecognitionResult($event)">
```
+##### Vue
+Register a custom element like so in `main.js`:
+
+```typescript
+Vue.registerElement("MLKitTextRecognition", () => require("nativescript-plugin-firebase/mlkit/textrecognition").MLKitTextRecognition);
+```
+
+Now you're able to use the registered element in your `.Vue` file:
+
+```vue
+
@@ -203,11 +268,52 @@ registerElement("MLKitFaceDetection", () => require("nativescript-plugin-firebas
detectionMode="accurate"
enableFaceTracking="true"
minimumFaceSize="0.2"
+ preferFrontCamera="true"
[torchOn]="torchOn"
(scanResult)="onFaceDetectionResult($event)">
```
+### Object detection and tracking
+
+
+[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/object-detection)
+
+#### Still image
+
+```typescript
+import { MLKitObjectDetectionResult } from "nativescript-plugin-firebase/mlkit/objectdetection";
+const firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.objectdetection.detectObjects({
+ image: imageSource, // a NativeScript Image or ImageSource, see the demo for examples
+ classify: true, // default false, attempts to classify the object(s) if true
+ multiple: true // default false, attempts to detect multiple objects (instead of only the most prominent one) when true
+})
+.then((result: MLKitObjectDetectionResult) => console.log(JSON.stringify(result.objects)))
+.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
+```
+
+#### Live camera feed
+The basics are explained above for 'Text recognition', so we're only showing the differences here.
+
+```typescript
+import { registerElement } from "nativescript-angular/element-registry";
+registerElement("MLKitObjectDetection", () => require("nativescript-plugin-firebase/mlkit/objectdetection").MLKitObjectDetection);
+```
+
+```html
+
@@ -221,6 +327,7 @@ const firebase = require("nativescript-plugin-firebase");
firebase.mlkit.barcodescanning.scanBarcodesOnDevice({
image: imageSource,
+ supportInverseBarcodes: true, // only set to true if you need this as it's degrades performance slightly
formats: [BarcodeFormat.QR_CODE, BarcodeFormat.CODABAR] // limit recognition to certain formats (faster), or leave out entirely for all formats (default)
})
.then((result: MLKitScanBarcodesOnDeviceResult) => console.log(JSON.stringify(result.barcodes)))
@@ -239,7 +346,10 @@ registerElement("MLKitBarcodeScanner", () => require("nativescript-plugin-fireba
@@ -295,6 +407,7 @@ registerElement("MLKitImageLabeling", () => require("nativescript-plugin-firebas
width="260"
height="380"
confidenceThreshold="0.6"
+ preferFrontCamera="false"
[torchOn]="torchOn"
(scanResult)="onImageLabelingResult($event)">
@@ -320,7 +433,182 @@ firebase.mlkit.landmarkrecognition.recognizeLandmarksCloud({
.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
```
+### Natural language identification
+
+
+[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/identify-languages)
+
+#### Still image
+Note that you could hook this up to text recognition running from a live camera stream, to get realtime results.
+Check [demo-ng](demo-ng) if you're interested in such a solution.
+
+```typescript
+import { MLKitNaturalLanguageIdentificationResult } from "nativescript-plugin-firebase/mlkit/naturallanguageidentification";
+const firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.naturallanguageidentification.identifyNaturalLanguage({
+ text: "Some text to detect the language for"
+})
+.then((languageIdResult: MLKitNaturalLanguageIdentificationResult) => console.log(`Language code: ${languageIdResult.languageCode}`))
+.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
+```
+
+### Translate text
+> ⚠️ Because of a model-download bug on iOS this feature currently only works on Android.
+
+
+
+[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/translation)
+
+#### Still image
+You could use MLKit to perform OCR, then identify the language, and then translate it to another language.
+Check [demo-ng](demo-ng) if you're interested in such an approach.
+
+```typescript
+const firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.translation.ensureTranslationModelDownloaded({
+ from: "nl",
+ to: "en"
+}).then(() => {
+ firebase.mlkit.translation.translateText({
+ from: "nl",
+ to: "en",
+ text: "De kat krabt de krullen van de trap" // some Dutch text
+ })
+ .then(result => console.log(`Translated to English: ${result}`))
+ .catch(console.error)
+}).catch(console.error);
+```
+
+### Smart reply
+
+
+[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/generate-smart-replies)
+
+#### Still image
+
+```typescript
+import { MLKitSmartReplyConversationMessage } from "nativescript-plugin-firebase/mlkit/smartreply";
+const firebase = require("nativescript-plugin-firebase");
+
+// build a converstation history MLKit can create suggestions for, in chronological order
+const conversation: Array
+
+[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/automl-image-labeling)
+
+> NOTE: currently only local models are supported (not cloud models), but it's fairly easy to add those so open an issue if you need it. See the demo-ng folder for an example.
+
+#### Still image (on-device)
+
+```typescript
+import { MLKitAutoMLResult } from "nativescript-plugin-firebase/mlkit/automl";
+const firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.automl.labelImage({
+ localModelResourceFolder: "leftright",
+ image: imageSource,
+ confidenceThreshold: 0.6 // this will only return labels with at least 0.6 (60%) confidence. Default 0.5.
+})
+.then((result: MLKitAutoMLResult) => console.log(JSON.stringify(result.labels)))
+.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
+```
+
+#### Live camera feed
+The basics are explained above for 'Text recognition', so we're only showing the differences here.
+
+```typescript
+import { registerElement } from "nativescript-angular/element-registry";
+registerElement("MLKitAutoML", () => require("nativescript-plugin-firebase/mlkit/automl").MLKitAutoML);
+```
+
+```html
+
+
[Firebase documentation 🌎](https://firebase.google.com/docs/ml-kit/use-custom-models)
-Coming soon. See issue #702.
+⚠️ **Please take note of the following:**
+
+- Currently only models bundled with your app can be used (not ones hosted on Firebase). That may change in the future.
+- Prefix the `localModelFile` and `labelsFile` below with `~/` so they point to your `app/` folder. This is for future compatibility, because I'd like to support loading models from the native bundle as well.
+- On Android, make sure the model is not compressed by adding [your model's file extension to app.gradle](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/57969d0a62d761bffb98b19db85af88bfae858dd/demo-ng/app/App_Resources/Android/app.gradle#L22).
+- Only "Quantized" models can be used. Not "Float" models, so `modelInput.type` below must be set to `QUANT`.
+- The `modelInput.shape` parameter below must specify your model's dimensions. If you're not sure, use the script in the paragraph "Specify the model's input and output" at [the Firebase docs](https://firebase.google.com/docs/ml-kit/ios/use-custom-models).
+- If you're using Webpack, make sure to have it copy the model and labels files to the bundled app as well. [Here's an example.](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/816a529be7f19bad1bbd572b77835ab8e557f32d/demo-ng/webpack.config.js#L275)
+
+#### Still image (on-device)
+
+```typescript
+import { MLKitCustomModelResult } from "nativescript-plugin-firebase/mlkit/custommodel";
+const firebase = require("nativescript-plugin-firebase");
+
+firebase.mlkit.custommodel.useCustomModel({
+ image: imageSource, // a NativeScript Image or ImageSource, see the demo for examples
+ maxResults: 10, // default 5 (limit numbers to this amount of results)
+ localModelFile: "~/custommodel/inception/inception_v3_quant.tflite", // see the demo, where the model lives in app/custommodel/etc..
+ labelsFile: "~/custommodel/inception/inception_labels.txt",
+ modelInput: [{ // Array
+
+> Without this enabled you will receive push messages in the foreground, but **NOT in the background** / when the app is killed.
+
+#### Copy the entitlements file
+The previous step created a the file`platforms/ios/YourAppName/(Resources/)YourAppName.entitlements`.
+Copy that file to `app/App_Resources/iOS/` (if it doesn't exist yet, otherwise merge its contents),
+so it's not removed when you remove and re-add the iOS platform. The relevant content for background push in that file is:
+
+```xml
+
+
+```typescript
+import { messaging, Message } from "nativescript-plugin-firebase/messaging";
+
+const model = new messaging.PushNotificationModel();
+model.iosSettings = new messaging.IosPushSettings();
+model.iosSettings.badge = false;
+model.iosSettings.alert = true;
+
+model.iosSettings.interactiveSettings = new messaging.IosInteractivePushSettings();
+model.iosSettings.interactiveSettings.actions = [
+ {
+ identifier: "OPEN_ACTION",
+ title: "Open the app (if closed)",
+ options: messaging.IosInteractiveNotificationActionOptions.foreground
+ },
+ {
+ identifier: "AUTH",
+ title: "Open the app, but only if device is not locked with a passcode",
+ options: messaging.IosInteractiveNotificationActionOptions.foreground | messaging.IosInteractiveNotificationActionOptions.authenticationRequired
+ },
+ {
+ identifier: "INPUT_ACTION",
+ title: "Tap to reply without opening the app",
+ type: "input",
+ submitLabel: "Fire!",
+ placeholder: "Load the gun..."
+ },
+ {
+ identifier: "INPUT_ACTION",
+ title: "Tap to reply and open the app",
+ options: messaging.IosInteractiveNotificationActionOptions.foreground,
+ type: "input",
+ submitLabel: "OK, send it",
+ placeholder: "Type here, baby!"
+ },
+ {
+ identifier: "DELETE_ACTION",
+ title: "Delete without opening the app",
+ options: messaging.IosInteractiveNotificationActionOptions.destructive
+ }
+];
+
+model.iosSettings.interactiveSettings.categories = [{
+ identifier: "GENERAL"
+}];
+
+model.onNotificationActionTakenCallback = (actionIdentifier: string, message: Message) => {
+ console.log(`onNotificationActionTakenCallback fired! Message: ${JSON.stringify(message)}, Action taken: ${actionIdentifier}`);
+};
+
+messaging.registerForInteractivePush(model);
+```
+
+To send an interactive push, add the `"category"` property to the notification, with a value corresponding to the `category` defined in the model you've registered in the app.
+The payload to trigger the notification in the screenshots above is:
+
+```json
+{
+ "aps": {
+ "alert": {
+ "title": "Realtime Custom Push Notifications",
+ "subtitle": "Now with iOS 10 support!",
+ "body": "Add multimedia content to your notifications"
+ },
+ "sound": "default",
+ "badge": 1,
+ "category": "GENERAL",
+ "showWhenInForeground": true,
+ "data": {
+ "foo": "bar"
+ }
+ }
+}
+```
+
+> *IMPORTANT* Use the `click_action` only for push notifications on iOS. When such a message is tapped in the Android notification center the app WON'T be opened. This will probably be fixed in the future.
+
+
+## Testing push notifications
+
+### iOS
+For testing notifications on iOS the easiest tool I found is [Pusher](https://github.com/noodlewerk/NWPusher):
+
+
+
+### Android
+For testing on Android I prefer using [Postman](https://www.getpostman.com/) to *POST* to the FCM REST API. Look at which headers you need to set, and how the payload needs to be added:
+
+
diff --git a/docs/PERFORMANCE_MONITORING.md b/docs/PERFORMANCE_MONITORING.md
new file mode 100644
index 00000000..12bac3b3
--- /dev/null
+++ b/docs/PERFORMANCE_MONITORING.md
@@ -0,0 +1,124 @@
+
+
+> Added in plugin version 7.3.0
+
+## Performance Monitoring?
+With Firebase Performance Monitoring you get insights into how your app performs from your users' point of view, with automatic and customized performance tracing.
+
+[Learn more here..](https://firebase.google.com/products/performance/)
+
+## Enabling Performance Monitoring
+To add this feature to your project, either:
+
+* Remove `firebase.nativescript.json` from the root of the project and run `npm i`, or
+* Edit that file and add `"performance_monitoring": true`.
+
+In both cases, remove the `/platforms` folder afterwards so the required native library will be added upon the next build.
+
+> ⚠️ It may take up to 12 hours before results pop up in your Firebase console, so be patient.
+
+> ℹ️ Per Firebase's documentation, by enabling this feature, Remote Config will be enabled as well. So you may be interested in [what Remote Config can do for your app](../REMOTECONFIG.md).
+
+## API
+
+### `startTrace`
+To be able to interact with a started trace, you can remember it in a property (in this case `firebaseTrace`):
+
+```typescript
+import { performance as firebasePerformance } from "nativescript-plugin-firebase";
+import { FirebaseTrace } from "nativescript-plugin-firebase/performance/performance";
+
+const firebaseTrace: FirebaseTrace = firebasePerformance.startTrace("myTrace");
+```
+
+Now you can call several functions on the remembered trace object, read on below. And don't forget to use `trace.stop` afterwards.
+
+### `trace.setValue`
+
+```typescript
+if (firebaseTrace) {
+ firebaseTrace.setValue("foo", "bar");
+}
+```
+
+### `trace.getValue`
+
+```typescript
+if (firebaseTrace) {
+ firebaseTrace.getValue("foo");
+}
+```
+
+### `trace.getAttributes`
+
+```typescript
+if (firebaseTrace) {
+ const attributes = firebaseTrace.getAttributes();
+ console.log(`trace attributes: ${attributes}`);
+}
+```
+
+### `trace.removeAttribute`
+
+```typescript
+if (firebaseTrace) {
+ const attributes = firebaseTrace.removeAttribute("foo");
+}
+```
+
+### `trace.incrementMetric`
+
+```typescript
+if (firebaseTrace) {
+ const incrementBy = 1;
+ const attributes = firebaseTrace.incrementMetric("foo_metric", incrementBy);
+}
+```
+
+### `trace.stop`
+To stop the trace, call `stop` on the remembered trace object:
+
+```typescript
+if (firebaseTrace) {
+ firebaseTrace.stop();
+ firebaseTrace = undefined;
+}
+```
+
+### `startHttpMetric`
+To be able to interact with a started HTTP metric, you can remember it in a property (in this case `firebaseHttpMetric`):
+
+```typescript
+import { performance as firebasePerformance } from "nativescript-plugin-firebase";
+import { FirebaseHttpMetric } from "nativescript-plugin-firebase/performance/performance";
+
+const firebaseHttpMetric: FirebaseHttpMetric = firebasePerformance.startHttpMetric("https://postman-echo.com/get", "GET");
+```
+
+Now you can call several functions on the remembered metric object, read on below. And don't forget to use `metric.stop` afterwards.
+
+### `metric.setRequestPayloadSize`
+
+```typescript
+if (firebaseHttpMetric) {
+ firebaseHttpMetric.setRequestPayloadSize(42);
+}
+```
+
+### `metric.setHttpResponseCode`
+
+```typescript
+if (firebaseHttpMetric) {
+ firebaseHttpMetric.setHttpResponseCode(200);
+}
+```
+
+### `metric.stop`
+To stop the metric, call `stop` on the remembered metric object:
+
+```typescript
+if (firebaseHttpMetric) {
+ firebaseHttpMetric.stop();
+ firebaseHttpMetric = undefined;
+}
+```
\ No newline at end of file
diff --git a/docs/STORAGE.md b/docs/STORAGE.md
index 8d0bff0f..9f5d5a21 100644
--- a/docs/STORAGE.md
+++ b/docs/STORAGE.md
@@ -1,19 +1,16 @@
+_Storage_ lets you upload and download files to/from Google Cloud Storage which is connected to your Firebase instance.
+
> NOTE: since plugin version 6.2.0 you have to use `firebase.storage.xxx` instead of `firebase.xxx`, because I've extracted storage-related functions into a separate module.
## Enabling Storage
-Since plugin version 3.4.0 you can use Firebase _Storage_ features.
-
-_Storage_ lets you upload and download files to/from Google Cloud Storage which is connected to your Firebase instance.
-
-If you didn't choose this feature during installation you can manually uncomment
-the relevant lines to add the SDK's to your app in
-[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).
+During plugin installation you'll be asked whether or not you use "Firebase Storage".
-Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.
+In case you're upgrading and you have the `firebase.nativescript.json` file in your project root, edit it and add: `"storage": true`.
+Then run `rm -rf platforms && rm -rf node_modules && npm i`.
-### Setting the storage bucket (optional since plugin version 6.5.0)
+### Setting the storage bucket (no longer required since plugin version 6.5.0)
If (in the odd situation) the storage bucket URL you want to use is different than the one in the downloaded config file,
you can tell Firebase what it should use instead.
@@ -62,6 +59,16 @@ You can either pass in a full local path to a file, or (as a convenience) use th
// determine the path to a file in the app/res folder
var logoPath = appPath + "/res/telerik-logo.png";
+ // if you don't want/need to include metadata, pass in an empty object ({}) to avoid errors
+ var metadata = {
+ contentType: "demo/test",
+ contentLanguage: "fr",
+ customMetadata: {
+ "foo": "bar",
+ "foo2": "bar2"
+ }
+ };
+
// now upload the file with either of the options below:
firebase.storage.uploadFile({
// optional, can be omitted since 6.5.0, and also be passed during init() as 'storageBucket' param so we can cache it (find it in the Firebase console)
@@ -76,7 +83,8 @@ You can either pass in a full local path to a file, or (as a convenience) use th
onProgress: function(status) {
console.log("Uploaded fraction: " + status.fractionCompleted);
console.log("Percentage complete: " + status.percentageCompleted);
- }
+ },
+ metadata
}).then(
function (uploadedFile) {
console.log("File uploaded: " + JSON.stringify(uploadedFile));
@@ -103,7 +111,16 @@ You can either pass in a full local path to a file, or (as a convenience) use th
const storageRef = firebaseWebApi.storage().ref();
const childRef = storageRef.child("uploads/images/telerik-logo-uploaded.png");
- childRef.put(fs.File.fromPath(logoPath)).then(
+ // if you don't want/need to include metadata, pass in an empty object ({}) to avoid errors
+ const metadata = {
+ contentType: "demo/test",
+ contentLanguage: "fr",
+ customMetadata: {
+ "foo": "bar",
+ "foo2": "bar2"
+ }
+ };
+ childRef.put(fs.File.fromPath(logoPath), metadata).then(
uploadedFile => console.log("Uploaded! " + JSON.stringify(uploadedFile)),
error => console.log("firebase.doWebUploadFile error: " + error)
);
@@ -211,6 +228,61 @@ In this example we'll determine the remote URL of the previously uploaded file.
```
+### listAll
+Note that your security rules must be version "2" for this to work,
+so if it fails try adding this at the top of your rules defined for your storage bucket: `rules_version = '2';`
+
+