You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install and deploy both the Firebase function and public directory to Firebase Hosting: cd functions && npm install && cd ../ && firebase deploy
Visit the public endpoint for the deployed sample app to Firebase Hosting, e.g. example-123.web.app
History of user presence (since this page was opened) shows on index.html, but index.js errors out due to missing firebase-database include.
Debug output
[Warning] TypeError: firebase.database is not a function. (In 'firebase.database()', 'firebase.database' is undefined) (index.js, line 155)
rtdb_and_local_fs_presence — index.js:70
(anonymous function) — index.js:152
(anonymous function) — promise.js:826
Re — promise.js:1166
Ce — promise.js:1140
(anonymous function) — promise.js:1111
fe — run.js:124
promiseReactionJob
[Warning] Please enable Anonymous Authentication in your Firebase project! (index.js, line 156)
Expected behavior
The following code in index.js results in User <Anonymous user id> is online being appended to the #history div in index.html, a status collection gets created in firestorm with a document for <Anonymous user id> and status/<Anonymous user id> gets added to Realtime Database.
firebase.firestore().collection('status').where('state','==','online').onSnapshot(function(snapshot){snapshot.docChanges().forEach(function(change){if(change.type==='added'){varmsg='User '+change.doc.id+' is online.';console.log(msg);// [START_EXCLUDE]history.innerHTML+=msg+'<br />';// [END_EXCLUDE]}if(change.type==='removed'){varmsg='User '+change.doc.id+' is offline.';console.log(msg);// [START_EXCLUDE]history.innerHTML+=msg+'<br />'// [END_EXCLUDE]}});});
Actual behavior
The page errors out with the above javascript error due to the missing firebase.database function. Nothing gets written to Firestore or Realtime Database from the client as a result of running this sample.
The text was updated successfully, but these errors were encountered:
Which sample has a bug?
presence-firestore
How to reproduce the issue
Firebase function
andpublic
directory toFirebase Hosting
:cd functions && npm install && cd ../ && firebase deploy
Firebase Hosting
, e.g.example-123.web.app
index.html
, butindex.js
errors out due to missingfirebase-database
include.Debug output
Expected behavior
The following code in
index.js
results inUser <Anonymous user id> is online
being appended to the#history
div inindex.html
, astatus
collection gets created in firestorm with a document for<Anonymous user id>
andstatus/<Anonymous user id>
gets added to Realtime Database.Actual behavior
The page errors out with the above javascript error due to the missing
firebase.database
function. Nothing gets written to Firestore or Realtime Database from the client as a result of running this sample.The text was updated successfully, but these errors were encountered: