Search code examples
flutterfirebase-analytics

How disable firebase analytics for the whole device ( a test device -android & iOS ) in flutter?


Specifically for flutter apps,

One way is to get the device id and then for each analytics call check if it is a test device or not. Is there a better way or function to do this at app level?

What if my test devices keep on changing all the time?


Solution

  • I think I found a way to make that happen. Of course, you have to do the query about which device it is, depending on how you recognize a test device. Probably via packages like "imei_plugin". We recognize this by the APi the app is connected to.

    If you know that the device is a test device, then all you have to do is the following:

    FirebaseAnalytics.instance.setAnalyticsCollectionEnabled(false);
    

    or true if you want to enable the collection of data.