Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Doc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jul 14, 2016
1 parent cf1858d commit d1e29f7
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 47 deletions.
47 changes: 9 additions & 38 deletions docs/CRASHREPORTING.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>

## Enabling Remote Config
Since plugin version 3.2.0 you can retrieve _Remote Config_ properties.
This feature lets you configure parameters in your Firebase instance like these:
## Enabling Crash Reporting
Nothing to do - since plugin version 3.4.2 this plugin automatically uploads
crashes to your Firebase Console. Just check the 'Crash' menu item every now and then.

<img src="images/remote-config.png" width="500px" height="482px" alt="Remote Config"/>
## Making sense of the stacktraces
Please read [the official docs](https://firebase.google.com/docs/crash/)
on what Crash reporting is and what you can do to have a better experience.

To enable support for Remote Config you need to manually adjust
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).

Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.

## Functions

### getRemoteConfig
Using this function you can retrieve the current values of the remote properties so you can change app behavior on the fly easily (feature toggles for instance).

```js
firebase.getRemoteConfig({
developerMode: false, // play with this boolean to get more frequent updates during development
cacheExpirationSeconds: 600, // 10 minutes, default is 12 hours.. set to a lower value during dev
properties: [{
key: "holiday_promo_enabled",
default: false
},
{
key: "coupons_left",
default: 100
},
{
key: "double_or_nothing",
default: 9.99
}]
}).then(
function (result) {
console.log("Remote Config last fetched at " + result.lastFetch);
console.log("Remote Config: " + JSON.stringify(result.properties));
console.log("Remote Config property 'coupons_left': " + result.properties.coupons_left);
}
);
```
## Future work
There's an option to send logs to Firebase along with the crash in order
to add some context. This is however currently problematic on iOS but we'll keep an eye out.
123 changes: 114 additions & 9 deletions docs/STORAGE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,118 @@
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>

## Enabling Crash Reporting
Nothing to do - since plugin version 3.4.2 this plugin automatically uploads
crashes to your Firebase Console. Just check the 'Crash' menu item every now and then.
## Enabling Storage
Since plugin version 3.4.0 you can use Firebase _Storage_ features.

## Making sense of the stacktraces
Please read [the official docs](https://firebase.google.com/docs/crash/)
on what Crash reporting is and what you can do to have a better experience.
_Storage_ lets you upload and download files to/from Google Cloud Storage which is connected to your Firebase instance.

## Future work
There's an option to send logs to Firebase along with the crash in order
to add some context. This is however currently problematic on iOS but we'll keep an eye out.
To enable support for Remote Config you need to manually adjust
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).

Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.

### Setting the storage bucket
You need to tell Firebase what your storage bucket is. You can retrieve it
from the Firebase console by pressing 'Storage' in the menu.

You can either pass it to the `init()` function as shown below,
or pass it as a property any time you're using a storage feature.
In theory the former is a little more efficient because it's cached by the plugin.

```js
firebase.init({
storageBucket: 'gs://n-plugin-test.appspot.com'
// any other options
});
```

## Functions

### uploadFile
You can either pass in a full local path to a file, or (as a convenience) use the `file-system` module that comes shipped with {N} as standard.

```js
// init the file-system module
var fs = require("file-system");

// grab a reference to the app folder
var appPath = fs.knownFolders.currentApp().path;

// determine the path to a file in the app/res folder
var logoPath = appPath + "/res/telerik-logo.png";

// now upload the file with either of the options below:
firebase.uploadFile({
// optional, can also be passed during init() as 'storageBucket' param so we can cache it (find it in the Firebase console)
bucket: 'gs://n-plugin-test.appspot.com',
// the full path of the file in your Firebase storage (folders will be created)
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
// option 1: a file-system module File object
localFile: fs.File.fromPath(logoPath),
// option 2: a full file path (ignored if 'localFile' is set)
localFullPath: logoPath
}).then(
function (uploadedFile)
console.log("File uploaded: " + JSON.stringify(uploadedFile));
},
function (error) {
console.log("File upload error: " + error);
};
);
```

### downloadFile
As with `uploadFile` you can either pass in a full local path to a file, or (as a convenience) use the `file-system` module that comes shipped with {N} as standard.

In this example we'll download the previously uploaded file to a certain path on the local filesystem.

```js
// init the file-system module
var fs = require("file-system");

// let's first determine where we'll create the file using the 'file-system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";

// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");

// now download the file with either of the options below:
firebase.downloadFile({
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
bucket: 'gs://n-plugin-test.appspot.com',
// the full path of an existing file in your Firebase storage
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
// option 1: a file-system module File object
localFile: fs.File.fromPath(logoPath),
// option 2: a full file path (ignored if 'localFile' is set)
localFullPath: logoPath
}).then(
function (uploadedFile)
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
};
);
```

### getDownloadUrl
If you just want to know the remote URL of a file in remote storage so you can either share it or download the file by any other means than `downloadFile` then use this method.

In this example we'll determine the remote URL of the previously uploaded file.

```js
firebase.getDownloadUrl({
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
bucket: 'gs://n-plugin-test.appspot.com',
// the full path of an existing file in your Firebase storage
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png'
}).then(
function (url)
console.log("Remote URL: " + url);
},
function (error) {
console.log("Error: " + error);
};
);
```

0 comments on commit d1e29f7

Please sign in to comment.