Enable InstabugSurvey APIs for android

This commit is contained in:
DevHossamHassan 2017-06-22 09:21:07 +02:00
parent 2545f7f8a4
commit c56f5fb87a
2 changed files with 80 additions and 4 deletions

View File

@ -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) {

View File

@ -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);
},
/**