Skip to content

Commit ddb019f

Browse files
committed
chore: reactivate repister with
1 parent ede65ab commit ddb019f

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

android/src/main/java/com/instabug/flutter/InstabugFlutterPlugin.java

+19-20
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,25 @@ public class InstabugFlutterPlugin implements FlutterPlugin, ActivityAware {
3939
* Embedding v1
4040
* This method is required for compatibility with apps that don't use the v2 embedding.
4141
*/
42-
// Uncomment this method for backward compatibility
43-
44-
// @SuppressWarnings("deprecation")
45-
// public static void registerWith(Object registrar) {
46-
// try {
47-
// // Use reflection to access the Registrar class and its methods
48-
// Class<?> registrarClass = Class.forName("io.flutter.plugin.common.PluginRegistry.Registrar");
49-
// Activity activity = (Activity) registrarClass.getMethod("activity").invoke(registrar);
50-
// Context context = (Context) registrarClass.getMethod("context").invoke(registrar);
51-
// BinaryMessenger messenger = (BinaryMessenger) registrarClass.getMethod("messenger").invoke(registrar);
52-
// FlutterRenderer renderer = (FlutterRenderer) registrarClass.getMethod("textures").invoke(registrar);
53-
//
54-
// // Set the activity and register with the context
55-
// InstabugFlutterPlugin.activity = activity;
56-
// registerWithContext(context.getApplicationContext(), messenger, renderer);
57-
// System.out.println("old app");
58-
// } catch (Exception e) {
59-
// Log.e(TAG, "Failed to register with v1 embedding. Cause: " + e);
60-
// }
61-
// }
42+
43+
@SuppressWarnings("deprecation")
44+
public static void registerWith(Object registrar) {
45+
try {
46+
// Use reflection to access the Registrar class and its methods
47+
Class<?> registrarClass = Class.forName("io.flutter.plugin.common.PluginRegistry.Registrar");
48+
Activity activity = (Activity) registrarClass.getMethod("activity").invoke(registrar);
49+
Context context = (Context) registrarClass.getMethod("context").invoke(registrar);
50+
BinaryMessenger messenger = (BinaryMessenger) registrarClass.getMethod("messenger").invoke(registrar);
51+
FlutterRenderer renderer = (FlutterRenderer) registrarClass.getMethod("textures").invoke(registrar);
52+
53+
// Set the activity and register with the context
54+
InstabugFlutterPlugin.activity = activity;
55+
registerWithContext(context.getApplicationContext(), messenger, renderer);
56+
System.out.println("old app");
57+
} catch (Exception e) {
58+
Log.e(TAG, "Failed to register with v1 embedding. Cause: " + e);
59+
}
60+
}
6261

6362
@Override
6463
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {

0 commit comments

Comments
 (0)