Use firebase with webGL build
How would I go about using firebase as a database with my WebGL build? What I know so far is that I probably have to interact with browser scripting, since there's no firebase SDK for WebGL. To communicate with Firebase I have to import a script as per the firebase for web guide, but I don't know how to import this script. What I've tried:
- Copy paste the script into a .jslib file and putting the file in the plugins for WebGL folder, both with and without the "mergeInto(LibraryManager.library, {//firebase.js here}"
- Using Dynamic Script Loading from this answer https://stackoverflow.com/a/950146
Both of these methods seem to cause the build to fail with these errors:
Failed running "C:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe" "C:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc" @"C:\Users\Emil\CloudStation\Koder\Unity\Flick\Assets..\Temp\emcc_arguments.resp"
Exception: Failed building WebGL Player.
UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors.
So I think that what I need to know is how to correctly import the firebase.js script.
Answer by Navadan · Aug 17, 2017 at 08:11 AM
I have solved it now. I ended up using the WWW module combined with this from firebase.
But it seems like you can't do authentication using the REST API? I don't see how you can realistically use a firebase database without authentication for the rules, how did you deal with that?
can u please show me the code how you did it . I want to build my game in 3 platforms iOS, Android and WebGL using Firebase but when i use firebase namespace its showing errors while building Game for WebGL platform. Please Help
As @peterworth pointed out, it doens't seem like you can do authentication using the REST API. At least not for Web GL, since anyone can see the json-request being send and recived. So I have now marked this as unanswered again, and am still looking for answer.
@Navadan Don't think it's possible. Lately, I did some research on using Firebase Storage with Auth (not for WebGL) and I stumbled upon a Q&A video made by a firebase dev and he happened to say that it's not possible with WebGL. However, since the video's release maybe they have made some improvements.
may you send me the code of how to use WWW module for firebase? please I search and work out for this very long time and i cannot have a right solution to solve the problem
Answer by ACCACORE · Mar 04, 2021 at 12:08 PM
Yuu could use this plugin: https://assetstore.unity.com/packages/tools/network/api-for-firebase-189910
Your answer
![](https://koobas.hobune.stream/wayback/20220612132829im_/https://answers.unity.com/themes/thub/images/avi.jpg)