|
1 | 1 | <img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/> |
2 | 2 |
|
3 | | -## Enabling Storage |
4 | | -Since plugin version 3.4.0 you can use Firebase _Storage_ features. |
| 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. |
5 | 6 |
|
6 | | -_Storage_ lets you upload and download files to/from Google Cloud Storage which is connected to your Firebase instance. |
| 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. |
7 | 10 |
|
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 | | -``` |
| 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. |
0 commit comments