Skip to content

Commit 4a3d57f

Browse files
committed
feat: add NDK crash reporting APIs
1 parent dd69dcc commit 4a3d57f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

android/src/main/java/com/instabug/flutter/modules/CrashReportingApi.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,12 @@ public void sendNonFatalError(@NonNull String jsonCrash, @Nullable Map<String, S
7070
}
7171
}
7272

73+
@Override
74+
public void setNDKEnabled(@NonNull Boolean isEnabled) {
75+
if (isEnabled) {
76+
CrashReporting.setNDKCrashesState(Feature.State.ENABLED);
77+
} else {
78+
CrashReporting.setNDKCrashesState(Feature.State.DISABLED);
79+
}
80+
}
7381
}

lib/src/modules/crash_reporting.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import 'dart:async';
44
import 'dart:convert';
5+
import 'dart:io';
56

67
import 'package:flutter/foundation.dart';
78
import 'package:instabug_flutter/src/generated/crash_reporting.api.g.dart';
@@ -116,4 +117,14 @@ class CrashReporting {
116117
);
117118
return crashData;
118119
}
120+
121+
/// Enables and disables NDK crash reporting.
122+
/// [boolean] isEnabled
123+
///
124+
/// Requires the [Instabug NDK package](https://pub.dev/packages/instabug_flutter_ndk) to be added to the project for this to work.
125+
static Future<void> setNDKEnabled(bool isEnabled) async {
126+
if (Platform.isAndroid) {
127+
return _host.setNDKEnabled(isEnabled);
128+
}
129+
}
119130
}

pigeons/crash_reporting.api.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ abstract class CrashReportingHostApi {
1212
String? fingerprint,
1313
String nonFatalExceptionLevel,
1414
);
15+
16+
void setNDKEnabled(bool isEnabled);
1517
}

0 commit comments

Comments
 (0)