GithubHelp home page GithubHelp logo

theankurpanchani / godot-android-module-firebase Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yalcin-ata/godot-android-module-firebase

0.0 1.0 0.0 30 KB

Godot Android module for Firebase.

License: Apache License 2.0

Java 100.00%

godot-android-module-firebase's Introduction

godot-android-module-firebase

Godot Android module for Firebase, written from scratch. This project replaces https://github.com/yalcin-ata/godot-plugin-firebase.

This works for Godot Engine's stable version 3.2 (not beta).

Follow the instructions below.

API documentation can be found here.

Instructions

Preparing project

  1. Download and start Godot 3.2. No need to build it on your own (compile, ...).

  2. Install Export Templates: select menu Editor > Manage Export Templates... and download for Current Version (3.2.stable)

  3. Install Android Build Template for your project: select menu Project > Install Android Build Template..., and then click Install. This will install the files in your project's directory (by adding [PROJECT]/android/build/).

  4. Select menu Project > Export, and Add... Android. After setting your Unique Name, keystore stuff etc, don't forget to turn on Use Custom Build. Then click Close.

  5. Run in [PROJECT]/android/:

    git clone https://github.com/yalcin-ata/godot-android-module-firebase
  6. From Firebase console download your project's google-services.json and copy/move it to [PROJECT]/android/build/.

    Notice:
    Remember to always download a new version of google-services.json whenever you make changes at the Firebase console!

Preparing Firebase Android Module

  1. Add following two lines at the bottom of [PROJECT]/android/build/gradle.properties:

    android.useAndroidX=true
    android.enableJetifier=true
    
  2. Change minSdk from 18 to 21 in [PROJECT]/android/build/config.gradle:

    minSdk : 21
  3. Change gradle version to 6.1.1 in [PROJECT]/android/build/gradle/wrapper/gradle-wrapper.properties:

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
  4. Edit [PROJECT]/android/godot-android-module-firebase/assets/godot-firebase-config.json to your needs.

    Notice:
    If TestAds for AdMob is set to true all your Ad Unit IDs will be ignored, and the official AdMob Test IDs will be used instead.

    How to completely remove unneeded features is explained below.

  5. Edit [PROJECT]/android/godot-android-modules-firebase/gradle.conf to match your applicationId:

    applicationId 'your.package.name'
  6. In [PROJECT]/android/godot-android-modules-firebase/AndroidManifest.conf edit the following section to match your needs:

    <!-- AdMob -->
    <meta-data
          android:name="com.google.android.gms.ads.APPLICATION_ID"
          android:value="ca-app-pub-ADMOB_APP_ID"/>
    <!-- AdMob -->
    
  7. In Godot select menu Project > Project Settings and go to Android: Modules to add the following line:

    org/godotengine/godot/Firebase
    • Alternative:
      edit [PROJECT]/project.godot and add somewhere the following lines:

    [android]
    modules="org/godotengine/godot/Firebase"
    

Setup is done, now you can take a look at the instructions here (API).

Removing Unneeded Features

Notice:
Never remove

implementation 'com.google.firebase:firebase-analytics:VERSION'

from gradle.conf as this is needed for Firebase.

If you want to remove some features completely (i.e. to reduce the app size, not interested in a feature, ...) follow these steps:

Let's assume you don't need Cloud Messaging:

  • in [PROJECT]/android/godot-android-modules-firebase/gradle.conf remove following lines:

    // Firebase Cloud Messaging
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'androidx.work:work-runtime:2.3.1'
    
  • in [PROJECT]/android/godot-android-modules-firebase/AndroidManifest.conf remove following lines:

    <!-- Firebase Cloud Messaging -->
    <service
       android:name="org.godotengine.godot.CloudMessagingService"
       android:exported="false">
       <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
       </intent-filter>
    </service>
    <!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
         See README(https://goo.gl/l4GJaQ) for more. -->
    <meta-data
       android:name="com.google.firebase.messaging.default_notification_icon"
       android:resource="@drawable/ic_stat_ic_notification" />
    <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
         notification message. See README(https://goo.gl/6BKBk7) for more. -->
    <meta-data
       android:name="com.google.firebase.messaging.default_notification_color"
       android:resource="@color/colorAccent" />
    <meta-data
       android:name="com.google.firebase.messaging.default_notification_channel_id"
       android:value="@string/default_notification_channel_id" />
    
  • in [PROJECT]/android/godot-android-modules-firebase/src/org.godotengine.godot.Firebase.java remove everything related to Cloud Messaging:

    // ===== Cloud Messaging
    "cloudmessaging_subscribe_to_topic", "cloudmessaging_unsubscribe_from_topic"
    

    Notice:
    Remove the last comma at the last method name in the registerClass() method call, i.e. change

    • // ===== Storage
      "storage_upload", "storage_download",<- this one
      
      to
    • // ===== Storage
      "storage_upload", "storage_download"
      

    // ===== Cloud Messaging
    if (config.optBoolean("CloudMessaging", false)) {
        Utils.logDebug("CloudMessaging initializing");
        CloudMessaging.getInstance(activity).init(firebaseApp);
    }
    

    // ===== Cloud Messaging
    public void cloudmessaging_subscribe_to_topic(final String topicName) {
       activity.runOnUiThread(new Runnable() {
          @Override
          public void run() {
             CloudMessaging.getInstance(activity).subscribeToTopic(topicName);
          }
       });
    }
    
    public void cloudmessaging_unsubscribe_from_topic(final String topicName) {
       activity.runOnUiThread(new Runnable() {
          @Override
          public void run() {
             CloudMessaging.getInstance(activity).unsubscribeFromTopic(topicName);
          }
       });
    }
    // ===== Cloud Messaging ======================================================
    
  • in [PROJECT]/android/godot-android-modules-firebase/src/org/godotengine/godot/ remove every class with names starting with CloudMessaging.

Done!

Authentication

  1. Go to project's Firebase Console > Authentication > Sign-in method > Google: enable.

  2. Generate SHA-1:

    • For release

      • Run in shell:

        keytool -list -v -alias  -keystore release.keystore

        (type afterwards your password)

      • Copy calculated SHA-1.

      • Go to project's Firebase Console > Project Settings (click on gear wheel icon):

        • Scroll down to Your apps and click on Add fingerprint,

        • Paste the copied SHA-1 and save.

    • For debug

      • Run in shell:

        keytool -list -v -alias  -keystore debug.keystore

        (type afterwards your password)

      • Copy calculated SHA-1.

      • Go to project's Firebase Console > Project Settings (click on gear wheel icon):

        • Scroll down to Your apps and click on Add fingerprint,

        • Paste the copied SHA-1 and save.

    • At project's Firebase Console > Project Settings (click on gear wheel icon):

      • Under Public settings is public-facing name, beginning with project-...: copy project-....

      • Edit [PROJECT]/android/godot-android-modules-firebase/res/values/strings.xml and edit the following line:

        <string name="server_client_id">project-.....
  3. From Firebase console download google-services.json and copy/move it to [PROJECT]/android/build/.

    Again:
    Remember to always download a new version of google-services.json whenever you make changes at the Firebase console!

In-App Messaging

Follow instructions at Firebase: Send a test message.

Cloud Messaging

For advanced users:

Optional: Edit [PROJECT]/android/godot-android-module-firebase/res/values/strings.xml and edit following line:

<string name="default_notification_channel_id">TO BE DONE

Links: Firebase Cloud Messaging client, Firebase Cloud Messaging receive


ADB Logging

Run in shell:

clear

(clear screen)

adb logcat -b all -c

(clear buffer cache)

adb -d logcat godot:V GoogleService:V Firebase:V StorageException:V StorageTask:V UploadTask:V FIAM.Headless:V DEBUG:V AndroidRuntime:V ValidateServiceOp:V *:S

godot-android-module-firebase's People

Contributors

yalcin-ata avatar

Watchers

 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.