|
25 | 25 | import com.instabug.library.user.UserEventParam;
|
26 | 26 | import com.instabug.library.OnSdkDismissedCallback;
|
27 | 27 | import com.instabug.library.bugreporting.model.Bug;
|
| 28 | +import com.instabug.library.temp.InstabugSurvey; |
28 | 29 |
|
29 | 30 | import com.instabug.reactlibrary.utils.ArrayUtil;
|
30 | 31 | import com.instabug.reactlibrary.utils.MapUtil;
|
@@ -951,6 +952,79 @@ public void onSdkDismissed(DismissType issueState, Bug.Type bugType) {
|
951 | 952 | }
|
952 | 953 | }
|
953 | 954 |
|
| 955 | + /** |
| 956 | + * Show any valid survey if exist |
| 957 | + * |
| 958 | + * @return return true if a valid survey was shown otherwise false |
| 959 | + */ |
| 960 | + @ReactMethod |
| 961 | + public void showSurveysIfAvailable() { |
| 962 | + try { |
| 963 | + mInstabug.showValidSurvey(); |
| 964 | + } catch (java.lang.Exception exception) { |
| 965 | + exception.printStackTrace(); |
| 966 | + } |
| 967 | + } |
| 968 | + |
| 969 | + /** |
| 970 | + * Show any valid survey if exist |
| 971 | + * |
| 972 | + * @return return true if a valid survey was shown otherwise false |
| 973 | + */ |
| 974 | + @ReactMethod |
| 975 | + public void setSurveysEnabled(boolean surveysEnabled) { |
| 976 | + try { |
| 977 | + InstabugSurvey.setSurveysAutoShowing(surveysEnabled); |
| 978 | + } catch (java.lang.Exception exception) { |
| 979 | + exception.printStackTrace(); |
| 980 | + } |
| 981 | + } |
| 982 | + |
| 983 | + |
| 984 | + /** |
| 985 | + * Sets the runnable that gets executed just before showing any valid survey<br/> |
| 986 | + * WARNING: This runs on your application's main UI thread. Please do not include |
| 987 | + * any blocking operations to avoid ANRs. |
| 988 | + * |
| 989 | + * @param preShowingSurveyRunnable to run on the UI thread before showing any valid survey |
| 990 | + */ |
| 991 | + @ReactMethod |
| 992 | + public void setWillShowSurveyHandler(final Callback willShowSurveyHandler) { |
| 993 | + try { |
| 994 | + Runnable willShowSurveyRunnable = new Runnable() { |
| 995 | + @Override |
| 996 | + public void run() { |
| 997 | + willShowSurveyHandler.invoke(); |
| 998 | + } |
| 999 | + }; |
| 1000 | + mInstabug.setPreShowingSurveyRunnable(willShowSurveyRunnable); |
| 1001 | + } catch (java.lang.Exception exception) { |
| 1002 | + exception.printStackTrace(); |
| 1003 | + } |
| 1004 | + } |
| 1005 | + |
| 1006 | + /** |
| 1007 | + * Sets the runnable that gets executed just after showing any valid survey<br/> |
| 1008 | + * WARNING: This runs on your application's main UI thread. Please do not include |
| 1009 | + * any blocking operations to avoid ANRs. |
| 1010 | + * |
| 1011 | + * @param afterShowingSurveyRunnable to run on the UI thread after showing any valid survey |
| 1012 | + */ |
| 1013 | + @ReactMethod |
| 1014 | + public void setDidDismissSurveyHandler(final Callback didDismissSurveyHandler) { |
| 1015 | + try { |
| 1016 | + Runnable didDismissSurveyRunnable = new Runnable() { |
| 1017 | + @Override |
| 1018 | + public void run() { |
| 1019 | + didDismissSurveyHandler.invoke(); |
| 1020 | + } |
| 1021 | + }; |
| 1022 | + mInstabug.setAfterShowingSurveyRunnable(didDismissSurveyRunnable); |
| 1023 | + } catch (java.lang.Exception exception) { |
| 1024 | + exception.printStackTrace(); |
| 1025 | + } |
| 1026 | + } |
| 1027 | + |
954 | 1028 | private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
|
955 | 1029 | String keyInLowerCase = key.toLowerCase();
|
956 | 1030 | switch (keyInLowerCase) {
|
|
0 commit comments