Hi @Axel_Saucedo,
There isn’t an example, that I know of, to demonstrate adding Firebase to a Playcanvas project. But it’s quite easy, here are some steps:
- Add the Firebase SDKs to your Playcanvas project. Download the firebase .js files for the relevant components (firebase-app.js, firebase-auth.js etc.) and upload them to your Playcanvas project.
You can find links to those files in this guide, step 3:
https://firebase.google.com/docs/web/setup
- Make sure all Firebase SDK scripts are first in your scripts loading order:
https://developer.playcanvas.com/en/user-manual/scripting/loading-order/
- Grab the firebase config object from your google firebase dashboard. It will look like this:
var firebaseConfig = {
apiKey: "api-key",
authDomain: "project-id.firebaseapp.com",
databaseURL: "https://project-id.firebaseio.com",
projectId: "project-id",
storageBucket: "project-id.appspot.com",
messagingSenderId: "sender-id",
appId: "app-id",
measurementId: "G-measurement-id",
};
- You are ready to initialize the firebase app, you can put this code in any regular Playcanvas script. The initialize method will be a good place for that:
MyScript.prototype.initialize = function(){
var firebaseConfig = {
// ...
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
};