FirebaseConfig

The FirebaseConfig item allows to define account properties for FirebaseAuth and FirebaseDatabase. More...

Import Statement: import VPlayPlugins 1.0
Inherits:

PluginItem

Properties

Detailed Description

This item defines an optional custom account configuration to use for the Firebase items. Per default, the account configuration is included in google-services.json on Android and GoogleService-info.plist on iOS. If you only use one Firebase account, you do not need to instantiate FirebaseConfig manually. Simply add the config files to your project and start using FirebaseAuth and FirebaseDatabase.

Using FirebaseConfig, you can use multiple Firebase accounts from within one V-Play app. Create an instance of FirebaseConfig in QML and reference it with the properties FirebaseAuth::config and FirebaseDatabase::config.

Example usage:

 FirebaseAuth {
   id: customAuth

   //assign custom config values - override config from google-services.json / GoogleService-info.plist
   config: FirebaseConfig {
     //get these values from the firebase console
     projectId: "projectabc-1234"
     databaseUrl: "https://projectabc-1234.firebaseio.com/"

     //platform dependent - get these values from the google-services.json / GoogleService-info.plist
     apiKey:        Qt.platform.os === "android" ? "android-key"           : "ios-key"
     applicationId: Qt.platform.os === "android" ? "1:abcdef:android:1234" : "1:abcdef:ios:1234"
   }

   onFirebaseReady: loginUser("username", "pw")
 }

To be able to use database with authentication and custom Firebase account details, be sure to use the same FirebaseConfig instance for both these types, as in the following example.

 App {
   //this object can override the default firebase config when used in FirebaseAuth/Database
   FirebaseConfig {
     id: customConfig

     //get these values from the firebase console
     projectId: "projectabc-1234"
     databaseUrl: "https://projectabc-1234.firebaseio.com/"

     //platform dependent - get these values from the google-services.json / GoogleService-info.plist
     apiKey:        Qt.platform.os === "android" ? "android-key"           : "ios-key"
     applicationId: Qt.platform.os === "android" ? "1:abcdef:android:1234" : "1:abcdef:ios:1234"
   }

   FirebaseAuth {
     id: defaultAuth

     //config not assigned - use default auth with values from google-services.json / GoogleService-info.plist

     onFirebaseReady: loginUser("username", "pw")
   }

   FirebaseAuth {
     id: customAuth

     //assign custom config values
     config: customConfig

     onFirebaseReady: loginUser("username", "pw")
   }

   FirebaseDatabase {
     id: defaultDb

     //config not assigned - use default DB with values from google-services.json / GoogleService-info.plist

     onFirebaseReady: getValue("public/myDbValue")
   }

   FirebaseDatabase {
     id: customDb

     //assign custom config values
     config: customConfig

     onFirebaseReady: getValue("public/myDbValue")
   }

   //use auth and database in app...
 }

Note: Check out the Firebase Plugin page for more examples!

Property Documentation

apiKey : string

Defines the Firebase API key. It is platform dependent and will thus be different for Android and iOS.

On Android, you can find it in the google-services.json under "api_key". Example:

 "api_key": [
   {
     "current_key": "[your-API-key]"
   }
 ]

On iOS, you can find it in the GoogleService-info.plist under API_KEY. Example:

 <key>API_KEY</key>
 <string>[your-API-key]</string>

Note: This property is required when using FirebaseConfig.


applicationId : string

Defines the Firebase application ID. It is platform dependent and will thus be different for Android and iOS. You can find it in the Firebase console when selecting an app in settings.

Note: This property is required when using FirebaseConfig.


databaseUrl : string

Defines the Firebase database URL. It is platform independent and will thus be the same for Android and iOS. You can find it in the Firebase console when selecting a database.


projectId : string

Defines the Firebase project ID. It is platform independent and will thus be the same for Android and iOS. You can find it in the Firebase console when selecting an app in settings.


Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support