-
Notifications
You must be signed in to change notification settings - Fork 17
Applying Firebase configuration in MobileMessaging SDK
Olga Koroleva edited this page Nov 9, 2022
·
1 revision
MobileMessaging SDK supports following ways of applying Firebase configuration:
- [Preferable] Add a Firebase configuration file (google-services.json) as described in Firebase documentation
If you want to switch between types of configuration clean your project first, otherwise you can receive "Duplicate resources" errors.
- Add key/values from
google-services.json
to resource strings (strings.xml
). Documentation of the Google Services Gradle Plugin gives the details of how to get these values fromgoogle-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>
apply plugin: 'com.google.gms.google-services'
line should be removed from the build.gradle file, if it was added
- Initialize FirebaseOptions object and provide it to MobileMessaging.Builder#withFirebaseOptions(FirebaseOptions) method. Documentation of the Google Services Gradle Plugin gives the details of how to get these values from
google-services.json
file.
val firebaseOptions = FirebaseOptions.Builder()
//required parameters
.setApiKey("AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8")
.setApplicationId("1:1035469437089:android:73a4fb8297b2cd4f")
.setProjectId("mydemoapp")
.build()
MobileMessaging.Builder(getApplication())
.withFirebaseOptions(firebaseOptions)
.build()
expand to see Java code
FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
//required parameters
.setApiKey("AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8")
.setApplicationId("1:1035469437089:android:73a4fb8297b2cd4f")
.setProjectId("mydemoapp")
.build();
new MobileMessaging.Builder(getApplication())
.withFirebaseOptions(firebaseOptions)
.build();
apply plugin: 'com.google.gms.google-services'
line should be removed from the build.gradle file, if it was added
If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing API- DEPRECATED- Android Manifest components
- Privacy settings
- In-app chat
- Infobip RTC calls and UI
- Backup rules