From cccb8d3557cedb87169849b881532f1b1f02b377 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Thu, 4 Jan 2018 11:57:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Android=20-=20Add=20api=20for=20has?= =?UTF-8?q?RespondedToSurvey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNInstabugReactnativeModule.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index e8869f0..478b56c 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -672,6 +672,26 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Returns true if the survey with a specific token was answered before. + * Will return false if the token does not exist or if the survey was not answered before. + * + * @param surveyToken the attribute key as string + * @param hasRespondedCallback A callback that gets invoked with the returned value of whether + * the user has responded to the survey or not. + * @return the desired value of whether the user has responded to the survey or not. + */ + @ReactMethod + public void hasRespondedToSurveyWithToken(String surveyToken, Callback hasRespondedCallback) { + boolean hasResponded; + try { + hasResponded = Instabug.hasRespondToSurvey(surveyToken); + hasRespondedCallback.invoke(hasResponded); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** * Shows survey with a specific token. * Does nothing if there are no available surveys with that specific token.