Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

FirebaseConfig

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

Import Statement: import Felgo 4.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.

Note: If you are using the Felgo Developer app on iOS and Android, a public test database is used. Do not store any sensitive data when trying the Firebase Plugin with the Felgo Developer App. To use your own Firebase account, specify a custom FirebaseConfig or build your own QML Hot Reload Client app with your own google-services config.

Using FirebaseConfig, you can use multiple Firebase accounts from within one Felgo 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 for FirebaseDatabase. 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.


name : string

The name for this FirebaseConfig instance. This name is used for data persistence in the Firebase Plugin.

You can use more than one FirebaseConfig instance. In this case, assign a different unique name to each instance. These names should be constant and the same between app starts.

Example code:

 App {
   FirebaseConfig {
     id: config1
     name: "CustomConfig1"

     //config properties here
   }

   FirebaseConfig {
     id: config2
     name: "CustomConfig2"

     //config properties here
   }

   // instances of FirebaseAuth, FirebaseDatabase, ...
 }

The default value of this property is "VP_CUSTOM_FB_APP". If your app uses only one instance of FirebaseConfig, you do not need to assign to this property.


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.


storageBucket : string

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

Note: Use the storage bucket URL but without the leading gs:// protocol.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded