This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "rules": { | |
| "users": { | |
| "$user": { | |
| ".read": "auth.uid === $user", | |
| ".write": "auth.uid === $user" | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var firebase = new FirebaseClient( | |
| "https://dinosaur-facts.firebaseio.com/", | |
| new FirebaseOptions | |
| { | |
| AuthTokenAsyncFactory = () => "token value" | |
| }); | |
| var dinos = await firebase | |
| .Child("dinosaurs") | |
| .OnceAsync<Dinosaur>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // authenticate user with facebook and use the access token | |
| var token = "access_token_xyz"; | |
| // specify your app’s client key when creating the auth provider | |
| var ap = new FirebaseAuthProvider(new FirebaseAuthConfig("<YOUR APP API KEY>")); | |
| // sign in with OAuth. You can also sign in anonymously | |
| var auth = ap.SignInWithOAuth(FirebaseAuthType.Facebook, token); | |
| var firebase = new FirebaseClient( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get any Stream — it can be FileStream, MemoryStream or any other type of Stream | |
| var stream = File.Open(@"C:\YourFile.png", FileMode.Open); | |
| // Construct FirebaseStorage with path to where you want to upload the file and put it there | |
| var task = new FirebaseStorage("your-bucket.appspot.com") | |
| .Child("data") | |
| .Child("random") | |
| .Child("file.png") | |
| .PutAsync(stream); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as functions from 'firebase-functions'; | |
| import * as admin from 'firebase-admin'; | |
| import { Event } from 'firebase-functions'; | |
| import { DeltaSnapshot } from 'firebase-functions/lib/providers/database'; | |
| // intialize admin | |
| admin.initializeApp(functions.config().firebase); | |
| // export the function registration | |
| export let writeTransactionChange = functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "pushRegistrations": { | |
| "uid_1": { | |
| "push_token_1": { | |
| "platform": "android" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createRawPayload(userName: string, groupName: string, groupId: string, change: Change) | |
| { | |
| let payload = | |
| { | |
| data: | |
| { | |
| "by" : userName, | |
| "action" : change.action, | |
| "entity" : change.entity, | |
| "groupId" : groupId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // refresh currency rates | |
| export let refreshExchangeRates = functions | |
| .https | |
| .onRequest(async (request, response) => | |
| { | |
| await refreshExchangeRates(); | |
| response.end(); | |
| }); | |
| // functions to pull latest exchange rates and store them |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // change group currency task registration | |
| export let changeGroupCurrency = functions | |
| .database | |
| .ref('/serverTasks/currencyChange/{taskId}') | |
| .onWrite(event => changeGroupCurrency(event)); | |
| // function which changes group's currency and updates exchange rates of all expenses | |
| async function changeGroupCurrency(event: Event<DeltaSnapshot>) | |
| { | |
| // prevent triggering this function after writing response code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "serverTasks": { | |
| "currencyChange" : { | |
| "task_id_3": { | |
| "serverTimestamp": 21312321321, | |
| "request": { | |
| "groupId": "group_id_1", | |
| "targetCurrency": "CZK" | |
| }, | |
| "response": { |
OlderNewer