|
2 | 2 |
|
3 | 3 | import android.annotation.SuppressLint;
|
4 | 4 | import android.annotation.TargetApi;
|
| 5 | +import androidx.annotation.Nullable; |
5 | 6 |
|
6 | 7 | import com.facebook.react.bridge.Arguments;
|
7 | 8 | import com.facebook.react.bridge.Callback;
|
|
21 | 22 | import com.instabug.reactlibrary.utils.ArrayUtil;
|
22 | 23 | import com.instabug.reactlibrary.utils.EventEmitterModule;
|
23 | 24 | import com.instabug.reactlibrary.utils.MainThreadHandler;
|
| 25 | +import com.instabug.bug.userConsent.ActionType; |
24 | 26 |
|
25 | 27 | import java.util.ArrayList;
|
26 | 28 |
|
@@ -415,4 +417,30 @@ public void run() {
|
415 | 417 | }
|
416 | 418 | });
|
417 | 419 | }
|
| 420 | + |
| 421 | + /** |
| 422 | + * Adds a user consent item to the bug reporting |
| 423 | + * @param key A unique identifier string for the consent item. |
| 424 | + * @param description The text shown to the user describing the consent item. |
| 425 | + * @param mandatory Whether the user must agree to this item before submitting a report. |
| 426 | + * @param checked Whether the consent checkbox is pre-selected. |
| 427 | + * @param actionType A string representing the action type to map to SDK behavior. |
| 428 | + */ |
| 429 | + @ReactMethod |
| 430 | + public void addUserConsent(String key, String description, boolean mandatory, boolean checked, @Nullable String actionType) { |
| 431 | + MainThreadHandler.runOnMainThread(new Runnable() { |
| 432 | + @Override |
| 433 | + public void run() { |
| 434 | + try { |
| 435 | + String mappedActionType = ArgsRegistry.userConsentActionType.get(actionType); |
| 436 | + BugReporting.addUserConsent(key, description, mandatory, checked, mappedActionType); |
| 437 | + } catch (Exception e) { |
| 438 | + e.printStackTrace(); |
| 439 | + } |
| 440 | + } |
| 441 | + }); |
| 442 | + |
| 443 | + } |
| 444 | + |
| 445 | + |
418 | 446 | }
|
0 commit comments