mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-02 14:10:40 +00:00
Enable InstabugSurvey
APIs for android
This commit is contained in:
parent
2545f7f8a4
commit
c56f5fb87a
@ -25,6 +25,7 @@ import com.instabug.library.InstabugCustomTextPlaceHolder;
|
||||
import com.instabug.library.user.UserEventParam;
|
||||
import com.instabug.library.OnSdkDismissedCallback;
|
||||
import com.instabug.library.bugreporting.model.Bug;
|
||||
import com.instabug.library.temp.InstabugSurvey;
|
||||
|
||||
import com.instabug.reactlibrary.utils.ArrayUtil;
|
||||
import com.instabug.reactlibrary.utils.MapUtil;
|
||||
@ -951,6 +952,79 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show any valid survey if exist
|
||||
*
|
||||
* @return return true if a valid survey was shown otherwise false
|
||||
*/
|
||||
@ReactMethod
|
||||
public void showSurveysIfAvailable() {
|
||||
try {
|
||||
mInstabug.showValidSurvey();
|
||||
} catch (java.lang.Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show any valid survey if exist
|
||||
*
|
||||
* @return return true if a valid survey was shown otherwise false
|
||||
*/
|
||||
@ReactMethod
|
||||
public void setSurveysEnabled(boolean surveysEnabled) {
|
||||
try {
|
||||
InstabugSurvey.setSurveysAutoShowing(surveysEnabled);
|
||||
} catch (java.lang.Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the runnable that gets executed just before showing any valid survey<br/>
|
||||
* WARNING: This runs on your application's main UI thread. Please do not include
|
||||
* any blocking operations to avoid ANRs.
|
||||
*
|
||||
* @param preShowingSurveyRunnable to run on the UI thread before showing any valid survey
|
||||
*/
|
||||
@ReactMethod
|
||||
public void setWillShowSurveyHandler(final Callback willShowSurveyHandler) {
|
||||
try {
|
||||
Runnable willShowSurveyRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
willShowSurveyHandler.invoke();
|
||||
}
|
||||
};
|
||||
mInstabug.setPreShowingSurveyRunnable(willShowSurveyRunnable);
|
||||
} catch (java.lang.Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the runnable that gets executed just after showing any valid survey<br/>
|
||||
* WARNING: This runs on your application's main UI thread. Please do not include
|
||||
* any blocking operations to avoid ANRs.
|
||||
*
|
||||
* @param afterShowingSurveyRunnable to run on the UI thread after showing any valid survey
|
||||
*/
|
||||
@ReactMethod
|
||||
public void setDidDismissSurveyHandler(final Callback didDismissSurveyHandler) {
|
||||
try {
|
||||
Runnable didDismissSurveyRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
didDismissSurveyHandler.invoke();
|
||||
}
|
||||
};
|
||||
mInstabug.setAfterShowingSurveyRunnable(didDismissSurveyRunnable);
|
||||
} catch (java.lang.Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
|
||||
String keyInLowerCase = key.toLowerCase();
|
||||
switch (keyInLowerCase) {
|
||||
|
10
index.js
10
index.js
@ -656,9 +656,10 @@ module.exports = {
|
||||
'IBGWillShowSurvey',
|
||||
willShowSurveyHandler
|
||||
);
|
||||
|
||||
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
|
||||
}
|
||||
|
||||
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
|
||||
|
||||
},
|
||||
|
||||
setDidDismissSurveyHandler: function (didDismissSurveyHandler) {
|
||||
@ -668,9 +669,10 @@ module.exports = {
|
||||
'IBGDidDismissSurvey',
|
||||
didDismissSurveyHandler
|
||||
);
|
||||
|
||||
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);
|
||||
}
|
||||
|
||||
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user