Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud messaging doesn't work for Build variant on Android

I have 2 projects in Firebase: nl.companyname and nl.companyname.acc:

enter image description here

This is my build.gradle:

flavorDimensions "type"
productFlavors {
    acceptance {
        dimension="type"
        applicationIdSuffix ".acc"
        versionNameSuffix "-acc"
    }
    production {
        dimension="type"
        applicationIdSuffix ""
        versionNameSuffix ""
    }
}

The download google-services.json is in directory: app/google-services.json

Android Studio is logged in to the Google account and synchronized:

enter image description here

The message shows up as successfully sent: enter image description here

Problem description:

  • When sending a message on nl.companyname, it works.

  • When sending a message and targeting the device's Token ID, it works.

  • But the nl.companyname.acc doesn't work.

Steps tried:

  • I've deleted the .acc App in Firebase and re-added it (and downloaded the new json file).

enter image description here

Any help is greatly appreciated.

like image 972
Jim Clermonts Avatar asked May 27 '18 18:05

Jim Clermonts


People also ask

How does FCM work on Android?

The FCM backend receives the message request, generates a message ID and other metadata, and sends it to the platform specific transport layer. When the device is online, the message is sent via the platform-specific transport layer to the device. On the device, the client app receives the message or notification.


1 Answers

In the Firebase Document, it supports multiple flavor based project.

You can have multiple google-services.json files for different build variants) by placing google-services.json files in dedicated directories named for each variant under the app module root. For example, if you have "development" and "release" build flavors, your configuration could be organized like this:

app/
    google-services.json
    src/development/google-services.json
    src/release/google-services.json
    ...

You can find full instruction at here.

like image 197
wonsuc Avatar answered Oct 20 '22 00:10

wonsuc