Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Configure Firebase

How to use Firebase with the Optimizely Configured Commerce Mobile App.

You can use a Firebase account with your Optimizely Configured Commerce Mobile App.

Create a Firebase project

  1. Go to the Firebase Console.
  2. Log in with your Google account, or create one if needed.
  3. Click Add Project.
  4. Enter your project name, such as YourCompanyNameB2BApp.
  5. (Optional) Enter the Project ID if you want a custom identifier.
  6. Click Continue.
  7. Leave Google Analytics disabled. The Configured Commerce Mobile App has built-in analytics.
  8. Click Create Project.
  9. Wait for Firebase to finish provisioning.
  10. Click Continue to enter your new project dashboard.

Add your app to the Firebase project

You must add your mobile app (IOS or Android) to the Firebase project to use the services offered.

Android

  1. Go to the Firebase project settings.

  2. Click the Android icon under Add app to get started.

  3. Enter your app's applicationId from your app's android/app/build.gradle file from defaultConfig.

  4. (Optional) Add an app nickname.

  5. Click Register app.

  6. Click Download google-services.json.

  7. Place this file in your app’s android/app directory in your Android project.

iOS

  1. Go to the project settings.

  2. Click the iOS icon under Add app to get started.

  3. Enter your app's iOS bundle identifier (from Xcode).

  4. (Optional) Add an app nickname.

  5. Click Register app.

Update base_config.json

Update the following values in base_config.json, which help establish the connection between the app and firebase:

  • "firebaseAndroidApiKey"
  • "firebaseAndroidAppId"
  • "firebaseAndroidMessagingSenderId"
  • "firebaseAndroidProjectId"
  • "firebaseAndroidStorageBucket"
  • "firebaseIOSApiKey"
  • "firebaseIOSAppId"
  • "firebaseIOSMessagingSenderId"
  • "firebaseIOSProjectId"
  • "firebaseIOSStorageBucket"
  • "firebaseIOSBundleId"

You can collect these values from the google_service.json andGoogleService-Info.plist files. Look for these files by going to the project settings and selecting GoogleService-Info.plist for the app.

Map values for GoogleService-Info.plist

Map the following values from the GoogleService-Info.plist file.

  • "firebaseIOSApiKey" : "API_KEY",
  • "firebaseIOSAppId" : "GOOGLE_APP_ID",
  • "firebaseIOSMessagingSenderId" : "GCM_SENDER_ID",
  • "firebaseIOSProjectId" : "PROJECT_ID",
  • "firebaseIOSStorageBucket" : "STORAGE_BUCKET",
  • "firebaseIOSBundleId" : "BUNDLE_ID"

Map values for google_services.json

Map the following values from the google_services.json file. If you have multiple clients in the file, copy the one where your Android application ID matches the package_name inside that client.

  • "firebaseAndroidApiKey" : "current_key",
  • "firebaseAndroidAppId" : "mobilesdk_app_id,
  • "firebaseAndroidMessagingSenderId" : "project_number",
  • "firebaseAndroidProjectId" : "project_id",
  • "firebaseAndroidStorageBucket" : "storage_bucket",

Configure Firebase project for push notifications