Skip to content

Commit

Permalink
Improved firebase initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed May 26, 2021
1 parent ae28a0c commit 34d80ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
13 changes: 6 additions & 7 deletions firebase/api/firebase.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
type: function
desc: Initialise Firebase

- name: analytics.log
type: function
desc: Log an event with no parameters. (Official docs https://firebase.google.com/docs/reference/cpp/namespace/firebase/analytics#logevent_5)

parameters:
- name: name
return:
- name: success
type: boolean
desc: Indicates if initialisation was successful
- name: error
type: string
desc: Event name
desc: Error message if initialisation failed
22 changes: 12 additions & 10 deletions firebase/src/firebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,32 @@ using namespace firebase;


static int Firebase_Init(lua_State* L) {
DM_LUA_STACK_CHECK(L, 0);
dmLogInfo("Firebase_Init");
DM_LUA_STACK_CHECK(L, 2);

#if defined (DM_DEBUG)
// do some stuff for debug purposes
FIR_PlatformDebugInit();
#endif

#if defined(DM_PLATFORM_ANDROID)
dmLogInfo("Creating app");
JNIEnv* env = 0;
dmGraphics::GetNativeAndroidJavaVM()->AttachCurrentThread(&env, NULL);
firebase_app_ = App::Create(env, dmGraphics::GetNativeAndroidActivity());
#else
dmLogInfo("Creating app");
firebase_app_ = App::Create();
#endif

if(!firebase_app_) {
dmLogError("firebase::App::Create failed");
return 0;
if(!firebase_app_)
{
lua_pushboolean(L, 0);
lua_pushstring(L, "Failed to create Firebase App");
}
else
{
lua_pushboolean(L, 1);
lua_pushnil(L);
}

dmLogInfo("Firebase_Init done");
return 0;
return 2;
}


Expand Down

0 comments on commit 34d80ec

Please sign in to comment.