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

Commit d1e29f7

Browse files
Doc fix
1 parent cf1858d commit d1e29f7

File tree

2 files changed

+123
-47
lines changed

2 files changed

+123
-47
lines changed

docs/CRASHREPORTING.md

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,13 @@
11
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
22

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

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

9-
To enable support for Remote Config you need to manually adjust
10-
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).
11-
12-
Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.
13-
14-
## Functions
15-
16-
### getRemoteConfig
17-
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).
18-
19-
```js
20-
firebase.getRemoteConfig({
21-
developerMode: false, // play with this boolean to get more frequent updates during development
22-
cacheExpirationSeconds: 600, // 10 minutes, default is 12 hours.. set to a lower value during dev
23-
properties: [{
24-
key: "holiday_promo_enabled",
25-
default: false
26-
},
27-
{
28-
key: "coupons_left",
29-
default: 100
30-
},
31-
{
32-
key: "double_or_nothing",
33-
default: 9.99
34-
}]
35-
}).then(
36-
function (result) {
37-
console.log("Remote Config last fetched at " + result.lastFetch);
38-
console.log("Remote Config: " + JSON.stringify(result.properties));
39-
console.log("Remote Config property 'coupons_left': " + result.properties.coupons_left);
40-
}
41-
);
42-
```
11+
## Future work
12+
There's an option to send logs to Firebase along with the crash in order
13+
to add some context. This is however currently problematic on iOS but we'll keep an eye out.

docs/STORAGE.md

Lines changed: 114 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,118 @@
11
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
22

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

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

11-
## Future work
12-
There's an option to send logs to Firebase along with the crash in order
13-
to add some context. This is however currently problematic on iOS but we'll keep an eye out.
8+
To enable support for Remote Config you need to manually adjust
9+
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).
10+
11+
Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.
12+
13+
### Setting the storage bucket
14+
You need to tell Firebase what your storage bucket is. You can retrieve it
15+
from the Firebase console by pressing 'Storage' in the menu.
16+
17+
You can either pass it to the `init()` function as shown below,
18+
or pass it as a property any time you're using a storage feature.
19+
In theory the former is a little more efficient because it's cached by the plugin.
20+
21+
```js
22+
firebase.init({
23+
storageBucket: 'gs://n-plugin-test.appspot.com'
24+
// any other options
25+
});
26+
```
27+
28+
## Functions
29+
30+
### uploadFile
31+
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.
32+
33+
```js
34+
// init the file-system module
35+
var fs = require("file-system");
36+
37+
// grab a reference to the app folder
38+
var appPath = fs.knownFolders.currentApp().path;
39+
40+
// determine the path to a file in the app/res folder
41+
var logoPath = appPath + "/res/telerik-logo.png";
42+
43+
// now upload the file with either of the options below:
44+
firebase.uploadFile({
45+
// optional, can also be passed during init() as 'storageBucket' param so we can cache it (find it in the Firebase console)
46+
bucket: 'gs://n-plugin-test.appspot.com',
47+
// the full path of the file in your Firebase storage (folders will be created)
48+
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
49+
// option 1: a file-system module File object
50+
localFile: fs.File.fromPath(logoPath),
51+
// option 2: a full file path (ignored if 'localFile' is set)
52+
localFullPath: logoPath
53+
}).then(
54+
function (uploadedFile)
55+
console.log("File uploaded: " + JSON.stringify(uploadedFile));
56+
},
57+
function (error) {
58+
console.log("File upload error: " + error);
59+
};
60+
);
61+
```
62+
63+
### downloadFile
64+
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.
65+
66+
In this example we'll download the previously uploaded file to a certain path on the local filesystem.
67+
68+
```js
69+
// init the file-system module
70+
var fs = require("file-system");
71+
72+
// let's first determine where we'll create the file using the 'file-system' module
73+
var documents = fs.knownFolders.documents();
74+
var logoPath = documents.path + "/telerik-logo-downloaded.png";
75+
76+
// this will create or overwrite a local file in the app's documents folder
77+
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");
78+
79+
// now download the file with either of the options below:
80+
firebase.downloadFile({
81+
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
82+
bucket: 'gs://n-plugin-test.appspot.com',
83+
// the full path of an existing file in your Firebase storage
84+
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
85+
// option 1: a file-system module File object
86+
localFile: fs.File.fromPath(logoPath),
87+
// option 2: a full file path (ignored if 'localFile' is set)
88+
localFullPath: logoPath
89+
}).then(
90+
function (uploadedFile)
91+
console.log("File downloaded to the requested location");
92+
},
93+
function (error) {
94+
console.log("File download error: " + error);
95+
};
96+
);
97+
```
98+
99+
### getDownloadUrl
100+
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.
101+
102+
In this example we'll determine the remote URL of the previously uploaded file.
103+
104+
```js
105+
firebase.getDownloadUrl({
106+
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
107+
bucket: 'gs://n-plugin-test.appspot.com',
108+
// the full path of an existing file in your Firebase storage
109+
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png'
110+
}).then(
111+
function (url)
112+
console.log("Remote URL: " + url);
113+
},
114+
function (error) {
115+
console.log("Error: " + error);
116+
};
117+
);
118+
```

0 commit comments

Comments
 (0)