Skip to content

[Firebase Analytics] setAnalyticsCollectionEnabled(false) has no effect on iOS #90

@ToniTornado

Description

@ToniTornado

Describe the bug
FirebaseAnalytics().setAnalyticsCollectionEnabled(false); does not deactivate data collection on iOS.

To Reproduce
Call setAnalyticsCollectionEnabled(false) on your instance of FirebaseAnalytics. The Xcode log prints [Firebase/Analytics][I-ACS023012] Analytics enabled. All events are transmitted to the Firebase console.

Expected behavior
Transmission of events stops.

Additional context
The platform channel invokes the native iOS method in FirebaseAnalyticsPlugin.m:

} else if ([@"setAnalyticsCollectionEnabled" isEqualToString:call.method]) {
  NSNumber *enabled = [NSNumber numberWithBool:call.arguments];
  [FIRAnalytics setAnalyticsCollectionEnabled:[enabled boolValue]];
  result(nil);
}

call.arguments is of type __NSCFBoolean and the subsequent lines always convert the value that is passed to FIRAnalytics to true.

Add this code to the else if:

if ((int)call.arguments == 279097312) { // if passed false: 279097336
  NSLog(@"TRUE ARGUMENT WILL SET COLLECTION TO %@", [[NSNumber numberWithBool:call.arguments] boolValue] ? @"TRUE" : @"FALSE");
} else {
  NSLog(@"FALSE ARGUMENT WILL SET COLLECTION TO %@", [[NSNumber numberWithBool:call.arguments] boolValue] ? @"TRUE" : @"FALSE");
}

It prints
Runner[8875:2258309] TRUE ARGUMENT WILL SET COLLECTION TO TRUE
or
Runner[8875:2258309] FALSE ARGUMENT WILL SET COLLECTION TO TRUE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions