I have an app that has Firebase implemented. What I want is to disable everything related to Firebase before the user accepts the data collection consent. In android documentation I have seen that for example I can disable Firebase Analytics with:
setAnalyticsCollectionEnabled(false);
Okay, but what if I am using more services of Firebase?
Is there any way to disable everything related with Firebase so that any data is collected by any service of Firebase before the user has accepted the data collection consent?
2
Answers
There is no API for what you’re trying to do.
Your best bet is to simply not initialize Firebase at all until the time is right. An uninitialized Firebase SDK will do absolutely nothing in any of its products. You will have to instead do manual init and not the automated init that you get from a default integration.
Update apparently working:
I have followed "Take Control of Your Firebase Init on Android" article:
https://firebase.blog/posts/2017/03/take-control-of-your-firebase-init-on/
What I have done:
I have added to my root AndroidManifest.xml the following to disable automatic Provider merger as explained in the article:
After this I have manually initialized Firebase:
In OnCreate() method:
Note: I have not used.setDatabaseUrl("https://your-app.firebaseio.com"😉 as I not use Database Service.
Okay, this was not working form me (services were not working due that the provider isn’t merging now (this is totally expected), but initialization was not working and I din’t know why)
What I have done to make it work and don’t know why adding the following is working:
I have added
.setProjectId
to the builder and now is working as expected.