Android Question New Crashlytics how to disable reporting before get consent from user?

Pendrush

Well-Known Member
Licensed User
Longtime User
This post explain how to integrate new Crashlytics into our app.
The question is how to implement the library but so that it does not send data to the google server before we get the user's consent?
The issue is related to the GDPR law, which requires that the consent of the user be required before sending the data.
The law also strictly prohibits the sending of any data if the user is a child.
 

DonManfred

Expert
Licensed User
Longtime User
You can just ignore setting up CrashLytics when the user does not want it.
I mean Initialize call in starter service for ex.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
@Pendrush question is correct. There is nothing to initialize with the new crashlytics. It works automatically.

Based on the the instructions:

Manifest editor:
B4X:
AddApplicationText(<meta-data
    android:name="firebase_crashlytics_collection_enabled"
    android:value="false" />
)

Code:
B4X:
Public Sub CLLog(msg As String)
    GetCrashlytics.RunMethod("log", Array(msg))
    Log(msg)
End Sub

Private Sub GetCrashlytics As JavaObject
    Dim jo As JavaObject
    jo = jo.InitializeStatic("com.google.firebase.crashlytics.FirebaseCrashlytics").RunMethod("getInstance", Null)
    Return jo
End Sub

Enable:
B4X:
GetCrashlytics.RunMethod("setCrashlyticsCollectionEnabled", Array(True))
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
@Pendrush question is correct. There is nothing to initialize with the new crashlytics. It works automatically.

Based on the the instructions:

Manifest editor:
B4X:
AddApplicationText(<meta-data
    android:name="firebase_crashlytics_collection_enabled"
    android:value="false" />
)

Code:
B4X:
Public Sub CLLog(msg As String)
    GetCrashlytics.RunMethod("log", Array(msg))
    Log(msg)
End Sub

Private Sub GetCrashlytics As JavaObject
    Dim jo As JavaObject
    jo = jo.InitializeStatic("com.google.firebase.crashlytics.FirebaseCrashlytics").RunMethod("getInstance", Null)
    Return jo
End Sub

Enable:
B4X:
GetCrashlytics.RunMethod("setCrashlyticsCollectionEnabled", Array(True))

Enable opt-in reporting
By default, Crashlytics automatically collects crash reports for all your app's users. To give users more control over the data they send, you can enable opt-in reporting for your users by disabling automatic collection and initializing Crashlytics only for selected users:

  1. Turn off automatic collection by adding a new key to your Info.plist file:
    • Key: FirebaseCrashlyticsCollectionEnabled
    • Value: false
  2. Enable collection for select users by calling the Crashlytics data collection override at runtime. The override value persists across launches of your app so Crashlytics can automatically collect reports. To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app.
    SwiftObjective-C
    [[FIRCrashlytics crashlytics] setCrashlyticsCollectionEnabled:YES];

How can we do it for iOS?
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
How can we do it for iOS?

the B4i version seems to have an initialize function so you can use the method DonManfred suggested.


Wrapper: @Biswajit
Version: 1.01

  • Crashlytics
    • Functions:
      • Initialize (EventName As String)
        Initializes the library inside the Application_Start function.
        You should initialize FirebaseAnalytics before initializing this library.
      • TestCrash
        Call this for testing library integration. After a test crash open you app again to send the data to firebase. Then check firebase console.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
the B4i version seems to have an initialize function so you can use the method DonManfred suggested.

But lib mentions
Initializes the library inside the Application_Start function.
.
You can change your preference about GDPR at settings menu(which is not at Application_Start sub). This could be a problem?
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I think Application_start is suggested so that Crashlytics is running as early as possible. You could do this elsewhere.

Turning off Crashlytics once initalised does look like a problem. Perhaps @Biswajit can help?
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
How can we do it for iOS?
This wrapper uses old SDK. Will post the new version soon. For now do this,
B4X:
#PlistExtra: <key>firebase_crashlytics_collection_enabled</key><false/>
B4X:
Public Sub CLLog(msg As String)
    GetCrashlytics.RunMethod("CLS_LOG:", Array(msg))
    Log(msg)
End Sub

Private Sub GetCrashlytics As NativeObject
    Dim no As NativeObject
    no = no.Initialize("Crashlytics").RunMethod("sharedInstance", Null)
    Return no
End Sub
 
Upvote 0
Top