iOS Question NativeObject help

yiankos1

Active Member
Licensed User
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.
    Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)

How can we do this code for b4i?

I initialized first iFirebaseCrashlytics library and then:

B4X:
    #PlistExtra: <key>FirebaseCrashlyticsCollectionEnabled</key><false/>

B4X:
Private Sub GetCrashlytics As NativeObject
    Dim no As NativeObject
    no.Initialize("Crashlytics").RunMethod("crashlytics", Null)
    Return no
End Sub

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

i get this error
B4X:
Error occurred on line: 162 (settings)
Method not found: crashlytics, target: Crashlytics
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  result               +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 368
  result               -[B4INativeObject RunMethod::] + 216
  CoreFoundation       <redacted> + 144
  CoreFoundation       <redacted> + 292
  result               +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
  result               -[B4IShell runVoidMethod] + 232
  result               -[B4IShell raiseEventImpl:method:args::] + 1800
result               -[B4IShellBI raiseEvent:event:params:] + 1580
result               +[B4IDebug delegate:::] + 80
result               -[b4i_settings _getcrashlytics] + 208
result               -[ResumableSub_settings_ConsentStateAvailable resume::] + 3444
CoreFoundation       <redacted> + 144
CoreFoundation       <redacted> + 292
result               +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
result               -[B4IShell runMethod:] + 448
result               -[B4IShell raiseEventImpl:method:args::] + 2172
result               -[B4IShellBI raiseEvent:event:params:] + 1580
 
Last edited:

Semen Matusovskiy

Well-Known Member
Licensed User
Which Firebase frameworks do you use ? no.Initialize("Crashlytics") confuses me.
Let's imagine that you use https://www.b4x.com/b4i/files/Firebase250.zip

To include FirebaseCrashlytics it's necessary to add #AdditionalLib : FirebaseCrashlytics.framework.3 and
B4X:
#If OBJC
@import FirebaseCrashlytics;
#End If

2) Initializing.... Let's declare Private noCrashlytics As NativeObject in Process_Globals.
In Application_Start (after FirebaseAnalytics.Initialize)
B4X:
    noCrashlytics = noCrashlytics.Initialize ("FIRCrashlytics").RunMethod ("crashlytics", Null)
    noCrashlytics.Runmethod("setCrashlyticsCollectionEnabled:", Array (True))
As I see, we can set a value using setField also
B4X:
noCrashlytics.SetField ("crashlyticsCollectionEnabled", True)
 
Upvote 0
Top