How to use @firebase/app - 10 common examples

To help you get started, we’ve selected a few @firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / firebase_v5.x.x / flow_v0.104.x- / test_firebase.js View on Github external
// #1
const a1: firebase.app.App = firebase.initializeApp({
  apiKey: 'apiKey',
  databaseURL: 'databaseURL',
  projectId: '42',
})

// #2
// $ExpectError
const a2: firebase.app.App = firebase.initializeApp({
  storageBucker: 'storageBucket',
  projectId: '42',
})

// #3
const a3: app.App = app('DEFAULT')

// #4
firebase
  .auth()
  .createUserWithEmailAndPassword('email', 'password')
  .then()
  .catch()

// #5
firebase.auth().onAuthStateChanged(user => {
  if (user) {
    user.displayName
    user.email
    user.emailVerified
    user.photoURL
    user.isAnonymous
github jelly-fin / jelly-fin / src / firebase-app.js View on Github external
}
};

// A config file that contains your firebase project credentials (not included in the repo)
const CONFIG = tryRequire('./firebase-config.json') || {
    apiKey: "AIzaSyAcq_Vr-wbCjctpWIXJdeXBHnQgSqCLRY8",
    authDomain: "jellyfin-a9ff6.firebaseapp.com",
    databaseURL: "https://jellyfin-a9ff6.firebaseio.com",
    projectId: "jellyfin-a9ff6",
    storageBucket: "",
    messagingSenderId: "505439361090"
};


// Initialize Cloud Firestore through Firebase
const app = firebase.initializeApp(CONFIG);

const db = firebase.firestore();

// Disable deprecated features
db.settings({
    timestampsInSnapshots: true,
});

// Add a document to a collection
db.collection("test-collection").add({
    title: 'post title',
    content: 'This is the test post content.',
    date: new Date(),
})
    .then(docRef => {
        console.log('Document written with ID: ', docRef);
github ddmng / fontah / src / fx / firebase.js View on Github external
const connect = (props, dispatch) => {
    console.log("Connecting to ", props.config, props.name)
    const settings = { /* your settings... */
        timestampsInSnapshots: true
    };
    const db = firebase.initializeApp(props.config, props.name).firestore()
    db.settings(settings);

    db.collection("/sessions").doc().set({
        started: new Date()
    })

    console.log("dispatching", props.action)
    dispatch(props.action)
}
github DanielSchaffer / webpack-babel-multi-target-plugin / examples / angular-firebase / src / app / app.component.ts View on Github external
public ngOnInit(): void {
    firebase.initializeApp({
      apiKey: 'AIzaSyA9tQLQ5WJOBS7-e9zcdGkRKjaroRI0T18',
      authDomain: 'test-59779.firebaseapp.com',
      databaseURL: 'https://test-59779.firebaseio.com',
      projectId: 'test-59779',
      storageBucket: '',
      messagingSenderId: '289255988111',
    })
    this.message = GTG
    this.renderer.setStyle(this.document.body.parentElement, 'background', 'green')

    // use e2e ready since firebase uses an interval to poll for auth updates, which breaks protractor's angular
    // ready detection
    ready()
  }
github gorgias / gorgias-chrome / src / store / plugin-firestore.js View on Github external
// Firestore plugin
import firebase from '@firebase/app';
import '@firebase/auth';
import '@firebase/firestore';

import Config from '../background/js/config';
import firebaseConfig from './config-firebase';

import _GORGIAS_API_PLUGIN from './plugin-api';

// firebase
firebase.initializeApp(firebaseConfig);

var db = firebase.firestore();

db.enablePersistence().catch((err) => {
    console.log('Firestore Persistance Error', err);
});

function mock () {
    return Promise.resolve();
}

function fsDate (date) {
    if (!date) {
        return firebase.firestore.Timestamp.now();
    }

    return firebase.firestore.Timestamp.fromDate(date);
}
github jelly-fin / jelly-fin / src / firebase-app.js View on Github external
// A config file that contains your firebase project credentials (not included in the repo)
const CONFIG = tryRequire('./firebase-config.json') || {
    apiKey: "AIzaSyAcq_Vr-wbCjctpWIXJdeXBHnQgSqCLRY8",
    authDomain: "jellyfin-a9ff6.firebaseapp.com",
    databaseURL: "https://jellyfin-a9ff6.firebaseio.com",
    projectId: "jellyfin-a9ff6",
    storageBucket: "",
    messagingSenderId: "505439361090"
};


// Initialize Cloud Firestore through Firebase
const app = firebase.initializeApp(CONFIG);

const db = firebase.firestore();

// Disable deprecated features
db.settings({
    timestampsInSnapshots: true,
});

// Add a document to a collection
db.collection("test-collection").add({
    title: 'post title',
    content: 'This is the test post content.',
    date: new Date(),
})
    .then(docRef => {
        console.log('Document written with ID: ', docRef);
    })
    .catch(error => {
github MobileTribe / panda-lab / agent / src / components / auth / AuthPage.vue View on Github external
if (getRuntimeEnv() == RuntimeEnv.ELECTRON_RENDERER) {
                            vue.onSignInSuccessWithAuthResult();
                            return false;
                        } else {
                            return true;
                        }
                    },
                    uiShown: function () {
                        // The widget is rendered.
                        // Hide the loader.
                    }
                },
                signInSuccessUrl: '/home',
                signInOptions: Services.getInstance().config.authProviders,
            };
            let ui = firebaseui.auth.AuthUI.getInstance() ? firebaseui.auth.AuthUI.getInstance() : new firebaseui.auth.AuthUI(firebase.auth());
            ui.start('#firebaseui-auth-container', uiConfig);

            console.log(Services.getInstance().config.authProviders);
        }
github Sitecore / Sitecore.HabitatHome.Omni / fitness / app / src / services / SubscriptionService.js View on Github external
const getMessagingToken = async () => {
  try {
    const messaging = firebase.messaging();
    await messaging.requestPermission();
    const token = await messaging.getToken();
    // TODO: debugging
    console.log({ token });
    return token;
  } catch (error) {
    console.error(error);
    return null;
  }
};
github deckgo / deckdeckgo / studio / src / app / pages / core / app-signin / app-signin.tsx View on Github external
await this.mergeService.mergeDeck(mergeInfo.deckId, mergeInfo.userToken, user.id);

                // Delete previous anonymous user from our backend
                await this.userService.delete(mergeInfo.userId, mergeInfo.userToken);

                // Delete previous anonymous user from Firebase
                if (this.firebaseUser) {
                    await this.firebaseUser.delete();
                }

                await this.navigateRedirect();

                resolve();
            });

            await firebase.auth().signInWithCredential(cred);

            resolve();
        });
    };
github pubpub / pubpub-editor / src / addons / Collaborative / collaborativePlugin.js View on Github external
loadDocument() {
		if (this.startedLoad) { return null; }
		this.startedLoad = true;

		/* Authenticate with Firebase if a firebaseToken is provided in the client data */
		const authenticationFunction = this.localClientData.firebaseToken
			? firebase.auth(this.firebaseApp).signInWithCustomToken(this.localClientData.firebaseToken)
			: new Promise((resolve)=> { return resolve(); });

		return authenticationFunction
		.then(()=> {
			/* Load the checkpoint if available */
			return this.firebaseRef.child('checkpoint').once('value');
		})
		.then((checkpointSnapshot) => {
			const checkpointSnapshotVal = checkpointSnapshot.val() || { k: '0', d: { type: 'doc', attrs: { meta: {} }, content: [{ type: 'paragraph' }] } };

			this.mostRecentRemoteKey = Number(checkpointSnapshotVal.k);
			const newDoc = Node.fromJSON(this.view.state.schema, uncompressStateJSON({ d: checkpointSnapshotVal.d }).doc);

			/* Get all changes since mostRecentRemoteKey */
			const getChanges = this.firebaseRef.child('changes')
			.orderByKey()