How to disable all but FCM

1,282 views
Skip to first unread message

root...@gmail.com

unread,
Sep 12, 2018, 11:01:06 AM9/12/18
to Firebase Google Group
Hey Firebase team,

I am currently migrating an app from GCM to FCM. The need for cloud messaging is the only reason I need Firebase, I don't need any other firebase services.

Here's what I've done to obtain the minimal setup:

1) only include 'core' and 'fcm' modules in gradle files:

    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-messaging:17.3.1'

2) **avoid** using google-services plugin and google-services.json file

    // classpath 'com.google.gms:google-services:4.0.1'
    // apply plugin: 'com.google.gms.google-services'

3) disable FirebaseInitProvider and do initialize Firebase manually:

    // in AndroidManifest.xml
    <provider
        android:name="com.google.firebase.provider.FirebaseInitProvider"
        android:authorities="${applicationId}.firebaseinitprovider"
        android:exported="false"
        tools:node="remove"
        />

    // in Application class
    val firebaseOptions = FirebaseOptions.Builder()
        .setApplicationId("**masked**")
        .setGcmSenderId(**masked**)
        .build()
    FirebaseApp.initializeApp(this, firebaseOptions)

4) disable analytics from manifest as per docs for disabling Firebase Analytics:

    <meta-data
        android:name="firebase_analytics_collection_deactivated"
        android:value="true"
        />

    <meta-data
        android:name="google_analytics_adid_collection_enabled"
        android:value="false"
        />

5) remove receivers and serivces automerged from firebase-analytics's AndroidManifest:

    <receiver
        android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
        tools:node="remove"
        />

    <receiver
        android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
        tools:node="remove"
        />

    <service
        android:name="com.google.android.gms.measurement.AppMeasurementService"
        tools:node="remove"
        />

    <service
        android:name="com.google.android.gms.measurement.AppMeasurementJobService"
        tools:node="remove"
        />

With all the steps FCM push notifications do work correctly. 
However, as I see from verbose logging

    adb shell setprop log.tag.FA VERBOSE
    adb shell setprop debug.firebase.analytics.app <package-name>

Firebase still subscribes for lifecycle callbacks and lives its life there quite active:

09-12 16:58:31.032 5165-5165 V/FA: Registered activity lifecycle callback
09-12 16:58:31.141 5165-5202 I/FA: Collection disabled with firebase_analytics_collection_deactivated=1
09-12 16:58:31.180 5165-5202 I/FA: App measurement is starting up, version: 13001
    To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
09-12 16:58:31.212 5165-5202 I/FA: Faster debug mode event logging enabled. To disable, run:
      adb shell setprop debug.firebase.analytics.app .none.
09-12 16:58:31.212 5165-5202 D/FA: Debug-level message logging enabled
09-12 16:58:33.061 5165-5165 V/FA: onActivityCreated
09-12 16:58:33.319 5165-5202 D/FA: Event not sent since app measurement is disabled
09-12 16:58:33.324 5165-5202 V/FA: Connecting to remote service
09-12 16:58:33.390 5165-5202 V/FA: Activity resumed, time: 1188927
09-12 16:58:33.761 5165-5202 V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 446
09-12 16:58:33.783 5165-5202 V/FA: Connection attempt already in progress
09-12 16:58:33.785 5165-5202 V/FA: Activity paused, time: 1189366
09-12 16:58:34.037 5165-5165 V/FA: onActivityCreated
09-12 16:58:34.603 5165-5202 D/FA: Event not sent since app measurement is disabled
09-12 16:58:34.604 5165-5202 V/FA: Connection attempt already in progress
09-12 16:58:34.620 5165-5202 V/FA: Activity resumed, time: 1190181
09-12 16:58:34.841 5165-5202 D/FA: Connected to remote service
09-12 16:58:34.869 5165-5202 V/FA: Processing queued up service tasks: 3
09-12 16:58:35.772 5165-5165 V/FA: onActivityCreated
09-12 16:58:35.774 5165-5202 V/FA: Recording user engagement, ms: 1197
09-12 16:58:35.791 5165-5202 V/FA: Activity paused, time: 1191378
09-12 16:58:35.805 5165-5202 D/FA: Event not sent since app measurement is disabled
09-12 16:58:36.139 5165-5202 D/FA: Event not sent since app measurement is disabled
09-12 16:58:36.155 5165-5202 V/FA: Activity resumed, time: 1191724

What bothers me is that, while it does not send the analytics to the Firebase backend (I hope so), it is still performing a lot of work locally wasting the CPU. 
What is the worst part of the story is that I have no option of opting out in case I want to use push messages.

Is there an undocumented way of disabling this background activity?
If not, is there any other way to get push notifications working without applying Firebase?
Reply all
Reply to author
Forward
0 new messages