-
Notifications
You must be signed in to change notification settings - Fork 6
Applying Firebase configuration in MobileMessaging Flutter plugin
This documentation refers to the plugin versions 6.0.0 onwards and Gradle's Plugin DSL approach. For older plugin versions and imperative apply script method, see this document.
MobileMessaging Flutter plugin supports following ways of applying Firebase configuration:
- [Preferable] Using Firebase configuration file (google-services.json)
- Adding key/values from
google-services.json
to resource strings - Providing FirebaseOptions object to
InfobipMobilemessaging.init
method
If you want to switch between types of configuration clean your project first, otherwise you can receive "Duplicate resources" errors.
- Add "com.google.gms:google-services" in
android/settings.gradle
file:
plugins {
...
id "com.google.gms.google-services" version "4.3.10" apply false
}
- Add "com.google.gms:google-services" to
plugins
section at the end ofandroid/app/build.gradle
file to apply Google Services Gradle Plugin:
plugins {
...
id "com.google.gms.google-services"
}
- Setup Firebase for your project if it's not yet and add Firebase configuration file (google-services.json) to the app as described in
Firebase documentation
. Usually it needs to be added intoandroid/app
folder.
Add key/values from google-services.json
to resource strings (app/src/main/res/values/strings.xml
). Documentation of the Google Services Gradle Plugin gives the details of how to get these values from google-services.json
file.
<resources>
...
<! -- Required -->
<string name="google_app_id" translatable="false">1:1035469437089:android:73a4fb8297b2cd4f</string>
<string name="google_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string>
<string name="project_id" translatable="false">mydemoapp</string>
<! -- Optional -->
<string name="gcm_defaultSenderId" translatable="false">1035469437089</string>
<string name="default_web_client_id" translatable="false">337894902146-e4uksm38sne0bqrj6uvkbo4oiu4hvigl.apps.googleusercontent.com</string>
<string name="ga_trackingId" translatable="false">UA-65557217-3</string>
<string name="firebase_database_url" translatable="false">https://example-url.firebaseio.com</string>
<string name="google_crash_reporting_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string>
</resources>
id "com.google.gms.google-services"
line should be removed from theandroid/app/build.gradle file
, if it was added
Providing FirebaseOptions object to InfobipMobilemessaging.init
method
Documentation of the Google Services Gradle Plugin gives the details of how to get these values from google-services.json
file.
await InfobipMobilemessaging.init(
Configuration(
applicationCode: "Your Application Code",
inAppChatEnabled: true,
defaultMessageStorage: true,
androidSettings: AndroidSettings(
firebaseOptions: FirebaseOptions(
apiKey: "Some-API-Key",
applicationId: "1:1234567890:android:abc123",
projectId: "project-123ab"),
),
iosSettings: IOSSettings(
notificationTypes: ["alert", "badge", "sound"],
forceCleanup: false,
logging: true),
),
);
id "com.google.gms.google-services"
line should be removed from theandroid/app/build.gradle file
, if it was added
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
- Privacy settings
- In-app chat
- WebRTC Calls and UI
- Migration Guides