Code Monkey home page Code Monkey logo

firebase's Introduction

Google Firebase SDK (1.0.0 version) integration with Cocos2d-x v3

Prerequisites

iOS and Android samples for the Firebase C++ SDK.

https://firebase.google.com/docs/reference/gradle/#processing_the_json_file

For more information, see https://firebase.google.com/.

Steps

  1. add Firebase native SDK

    iOS

    proj.ios_mac/Analytics proj.ios_mac/GoogleService-Info.plist

    Android

    proj.android/libs/google-firebase.jar proj.android/libs/gps proj.android/libs/android-support-v4.jar

  2. Put Firebase SDK firebase_cpp_sdk in cocos2d/external/firebase_cpp_sdk

    cocos2d/external/firebase_cpp_sdk/Android.mk

  3. Modified cocos2d/cocos/Android.mk

    https://github.com/yinjimmy/firebase/blob/master/cocos2d/cocos/Android.mk#L89 https://github.com/yinjimmy/firebase/blob/master/cocos2d/cocos/Android.mk#L130

  4. Added to cocos2d/cocos/platform/android/jni/JniHelper.h function GetActivity to get Activity.

    https://github.com/yinjimmy/firebase/blob/master/cocos2d/cocos/platform/android/jni/JniHelper.h#L49 https://github.com/yinjimmy/firebase/blob/master/cocos2d/cocos/platform/android/jni/JniHelper.cpp#L126

  5. Modified proj.android/AndroidManifest.xml

    https://github.com/yinjimmy/firebase/blob/master/proj.android/AndroidManifest.xml#L11-L21 https://github.com/yinjimmy/firebase/blob/master/proj.android/AndroidManifest.xml#L45-L107

  6. Convert google-services.json to res/values/google-services.xml

    ./generate_xml_from_google_services_json.py -i google-services.json -o proj.android/res/values/google-services.xml
    

Test

https://github.com/yinjimmy/firebase/blob/master/Classes/AppDelegate.cpp#L4-L13 https://github.com/yinjimmy/firebase/blob/master/Classes/AppDelegate.cpp#L156

Error

12-02 22:16:47.683 24451-24490/org.cocosbox.firebase E/FirebaseCrash: Failed to initialize crash reporting
                                                                      java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
                                                                          at android.os.Handler.<init>(Handler.java:209)
                                                                          at android.os.Handler.<init>(Handler.java:123)
                                                                          at com.google.firebase.crash.internal.api.FirebaseCrashApiImpl.init(:com.google.android.gms.DynamiteModulesC:1175)
                                                                          at bot.onTransact(:com.google.android.gms.DynamiteModulesC:60)
                                                                          at android.os.Binder.transact(Binder.java:385)
                                                                          at com.google.firebase.crash.internal.zzd$zza$zza.zza(Unknown Source)
                                                                          at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
                                                                          at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.google.firebase.FirebaseApp.zza(Unknown Source)
                                                                          at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                                                                          at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                                                                          at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
                                                                          at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72)
                                                                          at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1548)
                                                                          at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)

...
...
...

12-02 22:16:47.737 24451-24490/org.cocosbox.firebase E/FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

missing step 4 and 5

got bellow message if success

12-02 22:11:00.693 20050-20104/org.cocosbox.firebase I/firebase: firebase::App initializing app org.cocosbox.firebase (default 1).
12-02 22:11:00.694 20050-20104/org.cocosbox.firebase W/firebase: firebase::AppOptions will be ignored as the default app has already been initialized.  To disable automatic app initialization remove or rename resources derived from google-services.json.

android ios

Lua

using https://github.com/satoren/kaguya for Lua binding.

https://github.com/yinjimmy/firebase/blob/master/Classes/AppDelegate.cpp#L21-L56

lua test code:

https://github.com/yinjimmy/firebase/blob/master/Classes/AppDelegate.cpp#L207-L221

firebase's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.