diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index e504b466c..5c7851c61 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -1,22 +1,19 @@ package com.instabug.reactlibrary; +import android.net.Uri; + import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.Callback; -import android.app.Application; import com.instabug.library.Instabug; -import com.instabug.library.InstabugColorTheme; -import com.instabug.library.InstabugTrackingDelegate; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.invocation.InstabugInvocationMode; -import com.instabug.library.invocation.util.InstabugFloatingButtonEdge; + import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; -import android.net.Uri; import java.util.Map; @@ -53,75 +50,70 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { private final String LOCALE_SWEDISH = "swedish"; private final String LOCALE_TURKISH = "turkish"; - public RNInstabugReactnativeModule(ReactApplicationContext reactContext,Instabug mInstabug) { - super(reactContext); - this.mInstabug = mInstabug; - } + public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Instabug mInstabug) { + super(reactContext); + this.mInstabug = mInstabug; + } - @Override - public String getName() { - return "Instabug"; - } + @Override + public String getName() { + return "Instabug"; + } - /** + /** * invoke sdk manually - * */ @ReactMethod - public void invoke() - { + public void invoke() { try { - mInstabug.invoke(); + mInstabug.invoke(); } catch (Exception e) { e.printStackTrace(); } } - /** + /** * invoke sdk manually with desire invocation mode * * @param invocation mode */ @ReactMethod - public void invokeWithInvocationMode(String invocationMode) - { + public void invokeWithInvocationMode(String invocationMode) { InstabugInvocationMode mode; if (invocationMode.equals(INVOCATION_MODE_NEW_BUG)) { mode = InstabugInvocationMode.NEW_BUG; } else if (invocationMode.equals(INVOCATION_MODE_NEW_FEEDBACK)) { mode = InstabugInvocationMode.NEW_FEEDBACK; - }else if (invocationMode.equals(INVOCATION_MODE_NEW_CHAT)){ + } else if (invocationMode.equals(INVOCATION_MODE_NEW_CHAT)) { mode = InstabugInvocationMode.NEW_CHAT; - }else if (invocationMode.equals(INVOCATION_MODE_CHATS_LIST)){ + } else if (invocationMode.equals(INVOCATION_MODE_CHATS_LIST)) { mode = InstabugInvocationMode.CHATS_LIST; } else { mode = InstabugInvocationMode.PROMPT_OPTION; } - try { - mInstabug.invoke(mode); + try { + mInstabug.invoke(mode); } catch (Exception e) { e.printStackTrace(); } } - /** + /** * Dismisses all visible Instabug views - * */ @ReactMethod - public void dismiss() - { + public void dismiss() { try { - mInstabug.dismiss(); + mInstabug.dismiss(); } catch (Exception e) { e.printStackTrace(); } } - /** + /** * Adds tag(s) to issues before sending them * * @param tags @@ -225,14 +217,15 @@ public void showIntroMessage() { } } - /** Set the primary color that the SDK will use to tint certain UI elements in the SDK + /** + * Set the primary color that the SDK will use to tint certain UI elements in the SDK * * @param primaryColorValue The value of the primary color , - * whatever this color was parsed from a resource color or hex color or RGB color values + * whatever this color was parsed from a resource color or hex color or RGB color values */ @ReactMethod public void setPrimaryColor(int primaryColor) { - try{ + try { mInstabug.setPrimaryColor(primaryColor); } catch (Exception e) { e.printStackTrace(); @@ -241,6 +234,7 @@ public void setPrimaryColor(int primaryColor) { /** * Sets whether attachments in bug reporting and in-app messaging are enabled or not. + * * @param {boolean} screenShot A boolean to enable or disable screenshot attachments. * @param {boolean} extraScreenShot A boolean to enable or disable extra screenshot attachments. * @param {boolean} galleryImage A boolean to enable or disable gallery image attachments. @@ -281,9 +275,9 @@ public void log(String message) { */ @ReactMethod public ArrayList getTags() { - ArrayList tags = new ArrayList(); + ArrayList tags = new ArrayList(); try { - tags=mInstabug.getTags(); + tags = mInstabug.getTags(); } catch (Exception e) { e.printStackTrace(); } @@ -292,7 +286,6 @@ public ArrayList getTags() { /** * Reset ALL tags added using {@link #addTags(String...)} - * */ @ReactMethod public void resetTags() { @@ -310,9 +303,9 @@ public void resetTags() { */ @ReactMethod public boolean isEnabled() { - boolean isEnabled=false; + boolean isEnabled = false; try { - isEnabled=mInstabug.isEnabled(); + isEnabled = mInstabug.isEnabled(); } catch (Exception e) { e.printStackTrace(); } @@ -322,7 +315,6 @@ public boolean isEnabled() { /** * Enables all Instabug functionality - * */ @ReactMethod public void enable() { @@ -335,7 +327,6 @@ public void enable() { /** * Disables all Instabug functionality - * */ @ReactMethod public void disable() { @@ -351,9 +342,9 @@ public void disable() { */ @ReactMethod public String getAppToken() { - String appToken=""; + String appToken = ""; try { - appToken = mInstabug.getAppToken(); + appToken = mInstabug.getAppToken(); } catch (Exception e) { e.printStackTrace(); } @@ -369,9 +360,9 @@ public String getAppToken() { */ @ReactMethod public int getUnreadMessagesCount() { - int unreadMessages = 0 ; + int unreadMessages = 0; try { - unreadMessages = mInstabug.getUnreadMessagesCount(); + unreadMessages = mInstabug.getUnreadMessagesCount(); } catch (Exception e) { e.printStackTrace(); } @@ -387,22 +378,22 @@ public int getUnreadMessagesCount() { */ @ReactMethod public void changeInvocationEvent(String invocationEventValue) { - InstabugInvocationEvent invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON; + InstabugInvocationEvent invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; try { //setting invocation event - if(invocationEventValue.equals(INVOCATION_EVENT_FLOATING_BUTTON)) { - invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON; - } else if(invocationEventValue.equals(INVOCATION_EVENT_TWO_FINGERS_SWIPE)) { - invocationEvent=InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT; - } else if(invocationEventValue.equals(INVOCATION_EVENT_SHAKE)) { - invocationEvent=InstabugInvocationEvent.SHAKE; - } else if(invocationEventValue.equals(INVOCATION_EVENT_SCREENSHOT)){ - invocationEvent=InstabugInvocationEvent.SCREENSHOT_GESTURE; - } else if(invocationEventValue.equals(INVOCATION_EVENT_NONE)) { - invocationEvent=InstabugInvocationEvent.NONE; + if (invocationEventValue.equals(INVOCATION_EVENT_FLOATING_BUTTON)) { + invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; + } else if (invocationEventValue.equals(INVOCATION_EVENT_TWO_FINGERS_SWIPE)) { + invocationEvent = InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT; + } else if (invocationEventValue.equals(INVOCATION_EVENT_SHAKE)) { + invocationEvent = InstabugInvocationEvent.SHAKE; + } else if (invocationEventValue.equals(INVOCATION_EVENT_SCREENSHOT)) { + invocationEvent = InstabugInvocationEvent.SCREENSHOT_GESTURE; + } else if (invocationEventValue.equals(INVOCATION_EVENT_NONE)) { + invocationEvent = InstabugInvocationEvent.NONE; } - mInstabug.changeInvocationEvent(invocationEvent); + mInstabug.changeInvocationEvent(invocationEvent); } catch (Exception e) { e.printStackTrace(); } @@ -417,7 +408,7 @@ public void changeInvocationEvent(String invocationEventValue) { @ReactMethod public void setChatNotificationEnabled(boolean isChatNotificationEnable) { try { - mInstabug.setChatNotificationEnabled(isChatNotificationEnable); + mInstabug.setChatNotificationEnabled(isChatNotificationEnable); } catch (Exception e) { e.printStackTrace(); } @@ -433,48 +424,48 @@ public void setChatNotificationEnabled(boolean isChatNotificationEnable) { @ReactMethod public void setDebugEnabled(boolean isDebugEnabled) { try { - mInstabug.setDebugEnabled(isDebugEnabled); + mInstabug.setDebugEnabled(isDebugEnabled); } catch (Exception e) { e.printStackTrace(); } } private Locale getLocaleByKey(String instabugLocale) { - String localeInLowerCase=instabugLocale.toLowerCase(); + String localeInLowerCase = instabugLocale.toLowerCase(); case LOCALE_ARABIC: - return new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC.getCountry()); + return new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC.getCountry()); case LOCALE_ENGLISH: - return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); + return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); case LOCALE_CZECH: - return new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry()); + return new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry()); case LOCALE_FRENCH: - return new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH.getCountry()); + return new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH.getCountry()); case LOCALE_GERMAN: - return new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN.getCountry()); + return new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN.getCountry()); case LOCALE_ITALIAN: - return new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN.getCountry()); + return new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN.getCountry()); case LOCALE_JAPANESE: - return new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE.getCountry()); + return new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE.getCountry()); case LOCALE_POLISH: - return new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH.getCountry()); + return new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH.getCountry()); case LOCALE_RUSSIAN: - return new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN.getCountry()); + return new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN.getCountry()); case LOCALE_SPANISH: - return new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH.getCountry()); + return new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH.getCountry()); case LOCALE_SWEDISH: - return new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH.getCountry()); + return new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH.getCountry()); case LOCALE_TURKISH: - return new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH.getCountry()); + return new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH.getCountry()); case LOCALE_PORTUGUESE_BRAZIL: - return new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale.PORTUGUESE_BRAZIL.getCountry()); + return new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale.PORTUGUESE_BRAZIL.getCountry()); case LOCALE_CHINESE_SIMPLIFIED: - return new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale.SIMPLIFIED_CHINESE.getCountry()); + return new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale.SIMPLIFIED_CHINESE.getCountry()); case LOCALE_CHINESE_TRADITIONAL: - return new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale.TRADITIONAL_CHINESE.getCountry()); + return new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale.TRADITIONAL_CHINESE.getCountry()); case LOCALE_KOREAN: - return new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN.getCountry()); + return new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN.getCountry()); default: - return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); + return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); } @Override diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java index fd9d30682..28fba5461 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java @@ -1,95 +1,94 @@ package com.instabug.reactlibrary; -import java.util.List; -import java.util.Arrays; -import java.util.Locale; -import java.util.ArrayList; -import java.util.Collections; import android.app.Application; import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.uimanager.ViewManager; import com.facebook.react.bridge.JavaScriptModule; +import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; - - +import com.facebook.react.uimanager.ViewManager; import com.instabug.library.Instabug; import com.instabug.library.InstabugColorTheme; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.invocation.util.InstabugFloatingButtonEdge; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + public class RNInstabugReactnativePackage implements ReactPackage { Application androidApplication; private String mAndroidApplicationToken; private Instabug mInstabug; private Instabug.Builder mBuilder; - private InstabugInvocationEvent invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON; - private InstabugColorTheme instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight; + private InstabugInvocationEvent invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; + private InstabugColorTheme instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight; + public RNInstabugReactnativePackage(Instabug instabug) { this.mInstabug = instabug; } - public RNInstabugReactnativePackage(String androidApplicationToken,Application application) { - this(androidApplicationToken,application,"button"); + public RNInstabugReactnativePackage(String androidApplicationToken, Application application) { + this(androidApplicationToken, application, "button"); } - public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue) { - this(androidApplicationToken,application,invocationEventValue,"light"); + public RNInstabugReactnativePackage(String androidApplicationToken, Application application, String invocationEventValue) { + this(androidApplicationToken, application, invocationEventValue, "light"); } - public RNInstabugReactnativePackage(String androidApplicationToken,Application application, - String invocationEventValue,String instabugColorThemeValue) { + public RNInstabugReactnativePackage(String androidApplicationToken, Application application, + String invocationEventValue, String instabugColorThemeValue) { this.androidApplication = application; this.mAndroidApplicationToken = androidApplicationToken; - //setting invocation event - if(invocationEventValue.equals("button")) { - this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON; - } else if(invocationEventValue.equals("swipe")) { - this.invocationEvent=InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT; - - } else if(invocationEventValue.equals("shake")) { - this.invocationEvent=InstabugInvocationEvent.SHAKE; - - } else if(invocationEventValue.equals("screenshot")){ - this.invocationEvent=InstabugInvocationEvent.SCREENSHOT_GESTURE; - - } else if(invocationEventValue.equals("none")) { - this.invocationEvent=InstabugInvocationEvent.NONE; - - } else { - this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON; - } - - //setting instabugColorTheme - if (instabugColorThemeValue.equals("light")) { - this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight; - } else if (instabugColorThemeValue.equals("dark")) { - this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeDark; - } else { - this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight; - } - - - mInstabug = new Instabug.Builder(this.androidApplication,this.mAndroidApplicationToken) - .setFloatingButtonOffsetFromTop(400) - .setTheme(this.instabugColorTheme) - .setInvocationEvent(this.invocationEvent) - .setIntroMessageEnabled(false) - .setAttachmentTypesEnabled(true, true, true, true, true) - .setShouldPlayConversationSounds(true) - .setEnableInAppNotificationSound(true) - .setEnableSystemNotificationSound(false) - .setPromptOptionsEnabled(true, true, true) - .setWillSkipScreenshotAnnotation(false) - .setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT) - .setLocale(new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry())) - .build(); + //setting invocation event + if (invocationEventValue.equals("button")) { + this.invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; + } else if (invocationEventValue.equals("swipe")) { + this.invocationEvent = InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT; + + } else if (invocationEventValue.equals("shake")) { + this.invocationEvent = InstabugInvocationEvent.SHAKE; + + } else if (invocationEventValue.equals("screenshot")) { + this.invocationEvent = InstabugInvocationEvent.SCREENSHOT_GESTURE; + + } else if (invocationEventValue.equals("none")) { + this.invocationEvent = InstabugInvocationEvent.NONE; + + } else { + this.invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; + } + + //setting instabugColorTheme + if (instabugColorThemeValue.equals("light")) { + this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight; + } else if (instabugColorThemeValue.equals("dark")) { + this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeDark; + } else { + this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight; + } + + + mInstabug = new Instabug.Builder(this.androidApplication, this.mAndroidApplicationToken) + .setFloatingButtonOffsetFromTop(400) + .setTheme(this.instabugColorTheme) + .setInvocationEvent(this.invocationEvent) + .setIntroMessageEnabled(false) + .setAttachmentTypesEnabled(true, true, true, true, true) + .setShouldPlayConversationSounds(true) + .setEnableInAppNotificationSound(true) + .setEnableSystemNotificationSound(false) + .setPromptOptionsEnabled(true, true, true) + .setWillSkipScreenshotAnnotation(false) + .setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT) + .setLocale(new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry())) + .build(); } @Override @@ -101,12 +100,12 @@ public List createNativeModules(ReactApplicationContext reactConte @Override public List> createJSModules() { - return Collections.emptyList(); + return Collections.emptyList(); } @Override public List createViewManagers(ReactApplicationContext reactContext) { - return Collections.emptyList(); + return Collections.emptyList(); } } \ No newline at end of file diff --git a/index.js b/index.js index 3461a1c8a..17bd7a82a 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ * @flow */ -import { NativeModules, NativeAppEventEmitter, Platform } from 'react-native'; +import {NativeModules, NativeAppEventEmitter, Platform} from 'react-native'; let {Instabug} = NativeModules; @@ -14,585 +14,585 @@ let {Instabug} = NativeModules; */ module.exports = { - /** - * Starts the SDK. - * This is the main SDK method that does all the magic. This is the only - * method that SHOULD be called. - * Should be called in constructor of the app registery component - * @param {string} token The token that identifies the app, you can find - * it on your dashboard. - * @param {invocationEvent} invocationEvent The event that invokes - * the SDK's UI. - */ - startWithToken: function(token, invocationEvent) { - Instabug.startWithToken(token, invocationEvent); - }, - - /** - * Invokes the SDK manually with the default invocation mode. - * Shows a view that asks the user whether they want to start a chat, report - * a problem or suggest an improvement. - */ - invoke: function() { - Instabug.invoke(); - }, - - /** - * Invokes the SDK with a specific mode. - * Invokes the SDK and show a specific view, instead of showing a prompt for - * users to choose from. - * @param {invocationMode} invocationMode Specifies which mode the - * SDK is going to start with. - */ - invokeWithInvocationMode: function(invocationMode) { - Instabug.invokeWithInvocationMode(invocationMode); - }, - - /** - * Dismisses any Instabug views that are currently being shown. - */ - dismiss: function () { - Instabug.dismiss(); - }, - - /** - * Attaches a file to each report being sent. - * A new copy of the file at fileLocation will be attached with each bug - * report being sent. - * Each call to this method overrides the file to be attached. - * The file has to be available locally at the provided path. - * @param {string} fileLocation Path to a file that's going to be attached - * to each report. - */ - // Not yet testsed - setFileAttachment: function(fileLocation) { - Instabug.setFileAttachment(fileLocation); - }, - - /** - * Attaches user data to each report being sent. - * Each call to this method overrides the user data to be attached. - * Maximum size of the string is 1,000 characters. - * @param {string} userData A string to be attached to each report, with a - * maximum size of 1,000 characters. - */ - setUserData: function(userData) { - Instabug.setUserData(userData); - }, - - /** - * Adds custom logs that will be sent with each report. - * @param {string} log Message to be logged. - */ - IBGLog: function(log) { - Instabug.IBGLog(log); - }, - - /** - * Sets whether the SDK is tracking user steps or not. - * Enabling user steps would give you an insight on the scenario a user has - * performed before encountering a bug or a crash. User steps are attached - * with each report being sent. - * @param {boolean} isUserStepsEnabled A boolean to set user steps tracking - * to being enabled or disabled. - */ - setUserStepsEnabled: function(isUserStepsEnabled) { - Instabug.setUserStepsEnabled(isUserStepsEnabled); - }, - - /** - * A callback that gets executed before sending each bug report. - * @callback preSendingHandler - */ - - /** - * Sets a block of code to be executed before sending each report. - * This block is executed in the background before sending each report. Could - * be used for attaching logs and extra data to reports. - * @param {preSendingHandler} preSendingHandler - A callback that gets executed before sending each bug - * report. - */ - setPreSendingHandler: function(preSendingHandler) { - Instabug.addListener('IBGpreSendingHandler'); - NativeAppEventEmitter.addListener( - 'IBGpreSendingHandler', - preSendingHandler - ); - - Instabug.setPreSendingHandler(preSendingHandler); - }, - - /** - * Sets a block of code to be executed just before the SDK's UI is presented. - * This block is executed on the UI thread. Could be used for performing any - * UI changes before the SDK's UI is shown. - * @callback preSendingHandler - */ - - /** - * Sets a block of code to be executed just before the SDK's UI is presented. - * This block is executed on the UI thread. Could be used for performing any - * UI changes before the SDK's UI is shown. - * @param {preInvocationHandler} preInvocationHandler - A callback that gets executed before invoking the SDK - */ - setPreInvocationHandler: function(preInvocationHandler) { - Instabug.addListener('IBGpreInvocationHandler'); - NativeAppEventEmitter.addListener( - 'IBGpreInvocationHandler', - preInvocationHandler - ); - - Instabug.setPreInvocationHandler(preInvocationHandler); - }, - - /** - * A callback that gets executed after the SDK's UI is dismissed. - * @callback postInvocationHandler - * @param {dismissType} dismissType How the SDK was dismissed. - * @param {reportType} reportType Type of report that has been sent. Will be set - * to IBGReportTypeBug in case the SDK has been dismissed without selecting a - * report type, so you might need to check issueState before reportType - */ - - /** - * Sets a block of code to be executed right after the SDK's UI is dismissed. - * This block is executed on the UI thread. Could be used for performing any - * UI changes after the SDK's UI is dismissed. - * @param {postInvocationHandler} postInvocationHandler - A callback to get executed after - * dismissing the SDK. - */ - setPostInvocatioHandler: function(postInvocationHandler) { - Instabug.addListener('IBGpostInvocationHandler'); - NativeAppEventEmitter.addListener( - 'IBGpostInvocationHandler', - function(payload) { - postInvocationHandler(payload['dismissType'], payload['reportType']); - } - ); - - Instabug.setPostInvocatioHandler(postInvocationHandler); - }, - - /** - * Present a view that educates the user on how to invoke the SDK with the - * currently set invocation event. - */ - showIntroMessage: function() { - Instabug.showIntroMessage(); - }, - - /** - * Sets the default value of the user's email and hides the email field - * from the reporting UI. - * Defaults to an empty string. - * @param {string} userEmail An email address to be set as the user's email. - */ - setUserEmail: function(userEmail) { - Instabug.setUserEmail(userEmail); - }, - - /** - * Sets the default value of the user's name to be included with all reports. - * Defaults to an empty string. - * @param {string} userName Name of the user to be set. - */ - setUserName: function(userName) { - Instabug.setUserName(userName); - }, - - /** - * Enables/disables screenshot view when reporting a bug/improvement. - * By default, screenshot view is shown when reporting a bug, but not when - * sending feedback. - * @param {boolean} willSkipeScreenshotAnnotation sets whether screenshot view is - * shown or not. Passing YES will show screenshot view for both feedback and - * bug reporting, while passing NO will disable it for both. - */ - setWillSkipScreenshotAnnotation: function(willSkipeScreenshotAnnotation) { - Instabug.setWillSkipScreenshotAnnotation(willSkipeScreenshotAnnotation); - }, - - /** - * return callback - * @callback messageCountCallback - * @param{number} responseCount Notifications count, or -1 incase the SDK has - * not been initialized. - */ - - /** - * Returns the number of unread messages the user currently has. - * Use this method to get the number of unread messages the user - * has, then possibly notify them about it with your own UI. - * @param {messageCountCallback} messageCountCallback callback with argument - * Notifications count, or -1 incase the SDK has not been initialized. - */ - getUnreadMessagesCount: function(messageCountCallback) { - Instabug.getUnreadMessagesCount(messageCountCallback); - }, - - /** - * Sets the event that invoke the feedback form. - * Default is set by `Instabug.startWithToken`. - * @param {invocattionEvent} invocationEvent Event that invokes the - * feedback form. - */ - setInvocationEvent: function(invocationEvent) { - Instabug.setInvocationEvent(invocationEvent); - }, - - /** - * Enables/disables the use of push notifications in the SDK. - * Defaults to YES. - * @param {boolean} isPushNotificationEnabled A boolean to indicate whether push - * notifications are enabled or disabled. - */ - setPushNotificationsEnabled: function(isPushNotificationEnabled) { - Instabug.setPushNotificationsEnabled(isPushNotificationEnabled); - }, - - /** - * Sets whether users are required to enter an email address or not when - * sending reports. - * Defaults to YES. - * @param {boolean} isEmailFieldRequired A boolean to indicate whether email - * field is required or not. - */ - setEmailFieldRequired: function(isEmailFieldRequired) { - Instabug.setEmailFieldRequired(isEmailFieldRequired); - }, - - /** - * Sets whether users are required to enter a comment or not when sending reports. - * Defaults to NO. - * @param {boolean} isCommentFieldRequired A boolean to indicate whether comment - * field is required or not. - */ - setCommentFieldRequired: function(isCommentFieldRequired) { - Instabug.setCommentFieldRequired(isCommentFieldRequired); - }, - - /** - * Sets the threshold value of the shake gesture for iPhone/iPod Touch and iPad. - * Default for iPhone is 2.5. - * Default for iPad is 0.6. - * @param {number} iPhoneShakingThreshold Threshold for iPhone. - * @param {number} iPadShakingThreshold Threshold for iPad. - */ - setShakingThresholdForiPhone: function(iphoneThreshold, ipadThreshold) { - Instabug.setShakingThresholdForiPhone(iphoneThreshold, ipadThreshold); - }, - - /** - * Sets the default edge and offset from the top at which the floating button - * will be shown. Different orientations are already handled. - * Default for `floatingButtonEdge` is `rectEdge.maxX`. - * Default for `floatingButtonOffsetFromTop` is 50 - * @param {rectEdge} floatingButtonEdge `maxX` to show on the right, - * or `minX` to show on the left. - * @param {numnber} offsetFromTop floatingButtonOffsetFromTop Top offset for - * floating button. - */ - setFloatingButtonEdge: function(floatingButtonEdge, offsetFromTop) { - Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop); - }, - - /** - * Sets the SDK's locale. - * Use to change the SDK's UI to different language. - * Defaults to the device's current locale. - * @param {locale} locale A locale to set the SDK to. - */ - setLocale: function(locale) { - if (Platform.OS === 'ios') { - Instabug.setLocale(locale); - } else if (Platform.OS === 'android') { - Instabug.changeLocale(locale); - } - }, - - /** - * Sets whether the intro message that gets shown on launching the app is - * enabled or not. - * Defaults to YES. - * @param {boolean} isIntroMessageEnabled A boolean to indicate whether the - * intro message is enabled or not. - */ - setIntroMessageEnabled: function(isIntroMessageEnabled) { - Instabug.setIntroMessageEnabled(isIntroMessageEnabled); - }, - - /** - * Sets the color theme of the SDK's whole UI. - * @param {colorTheme) colorTheme An `colorTheme` to set - * the SDK's UI to. - */ - setColorTheme: function(colorTheme) { - Instabug.setColorTheme(colorTheme); - }, - - /** - * Sets the primary color of the SDK's UI. - * Sets the color of UI elements indicating interactivity or call to action. - * To use, import processColor and pass to it with argument the color hex - * as argument. - * @param {color} color A color to set the UI elements of the SDK to. - */ - setPrimaryColor: function(primaryColor) { - Instabug.setPrimaryColor(primaryColor); - }, - - /** - * Appends a set of tags to previously added tags of reported feedback, - * bug or crash. - * @param {string[]} tags An array of tags to append to current tags. - */ - appendTags: function(tags) { - Instabug.appendTags(tags); - }, - - /** - * Manually removes all tags of reported feedback, bug or crash. - */ - resetTags: function () { - Instabug.resetTags(); - }, - - /** - * return callback - * @callback tagsCallback - * @param {string[]} tags of reported feedback, bug or crash. - */ - - /** - * Gets all tags of reported feedback, bug or crash. - * @param {tagsCallback} tagsCallback callback with argument tags of reported feedback, bug or crash. - */ - getTags: function(tagsCallback) { - Instabug.getTags(tagsCallback); - }, - - /** - * Overrides any of the strings shown in the SDK with custom ones. - * Allows you to customize any of the strings shown to users in the SDK. - * @param {string} string String value to override the default one. - * @param {strings} key Key of string to override. - */ - setStringToKey: function(string, key) { - Instabug.setString(string, key); - }, - - /** - * Sets whether attachments in bug reporting and in-app messaging are enabled or not. - * @param {boolean} screenShot A boolean to enable or disable screenshot attachments. - * @param {boolean} extraScreenShot A boolean to enable or disable extra - * screenshot attachments. - * @param {boolean} galleryImage A boolean to enable or disable gallery image - * attachments. In iOS 10+,NSPhotoLibraryUsageDescription should be set in - * info.plist to enable gallery image attachments. - * @param {boolean} voiceNote A boolean to enable or disable voice note attachments. - * In iOS 10+, NSMicrophoneUsageDescription should be set in info.plist to enable - * voiceNote attachments. - * @param {boolean} screenRecording A boolean to enable or disable screen recording attachments. - */ - setAttachmentTypesEnabled: function(screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording) { - Instabug.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording); - }, - - /** - * Enables/disables showing in-app notifications when the user receives a - * new message. - * @param {boolean} isChatNotificationEnabled A boolean to set whether - * notifications are enabled or disabled. - */ - setChatNotificationEnabled: function(isChatNotificationEnabled) { - Instabug.setChatNotificationEnabled(isChatNotificationEnabled); - }, - - /** - * A callback that gets executed when a new message is received. - * @callback onNewMessgaeHandler - */ - - /** - * Sets a block of code that gets executed when a new message is received. - * @param {onNewMessgaeHandler} onNewMessgaeHandler - A callback that gets - * executed when a new message is received. - */ - setOnNewMessageHandler: function(onNewMessgaeHandler) { - Instabug.addListener('IBGonNewMessageHandler'); - NativeAppEventEmitter.addListener( - 'IBGonNewMessageHandler', - onNewMessgaeHandler - ); - - Instabug.setOnNewMessageHandler(onNewMessgaeHandler); - }, - - /** - * Enables/disables prompt options when SDK is invoked. - * When only a single option is enabled, it become the default invocation mode. - * If all options are disabled, bug reporting becomes the default invocation mode. - * By default, all three options are enabled. - * @param {boolean} bugReportEnabled A boolean to indicate whether bug reports - * are enabled or disabled. - * @param {boolean} feedbackEnabled A boolean to indicate whether feedback is - * enabled or disabled. - * @param {boolean} chatEnabled A boolean to indicate whether chat is enabled - * or disabled. - */ - setPromptOptions: function(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled) { - Instabug.setPromptOptions(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled); - }, - - /** - * return callback - * @callback isInstabugNotificationCallback - * @param {boolean} isInstabugNotification - */ - - /** - * Checks if a notification is from Instabug. - * If you are using push notifications, use this method to check whether an - * incoming notification is from Instabug or not. If this method returns YES, - * you should call didReceiveRemoteNotification: to let the Instabug handle - * the notification. Otherwise, handle the notification on your own. - * @param {Object} dict Notification's userInfo - * @param {isInstabugNotificationCallback} isInstabugNotificationCallback callback with - * argument isInstabugNotification - */ - isInstabugNotification: function(dict, isInstabugNotificationCallback) { - Instabug.isInstabugNotification(dict, isInstabugNotificationCallback); - }, - - /** - * The event used to invoke the feedback form - * @readonly - * @enum {number} - */ - invocationEvent: { - none: Instabug.invocationEventNone, - shake: Instabug.invocationEventShake, - screenshot: Instabug.invocationEventScreenshot, - twoFingersSwipe: Instabug.invocationEventTwoFingersSwipe, - floatingButton: Instabug.invocationEventFloatingButton - }, - /** - * Type of SDK dismiss - * @readonly - * @enum {number} - */ - dismissType: { - submit: Instabug.dismissTypeSubmit, - cancel: Instabug.dismissTypeCancel, - addAttachment: Instabug.dismissTypeAddAttachment - }, - /** - * Type of report to be submit - * @readonly - * @enum {number} - */ - reportType: { - bug: Instabug.reportTypeBug, - feedback: Instabug.reportTypeFeedback - }, - /** - * The mode used upon invocating the SDK - * @readonly - * @enum {number} - */ - invocationMode: { - NA: Instabug.invocationModeNA, - newBug: Instabug.invocationModeNewBug, - newFeedback: Instabug.invocationModeNewFeedback, - newChat: Instabug.invocationModeNewChat, - chatsList: Instabug.invocationModeChatsList - }, - /** - * The supported locales - * @readonly - * @enum {number} - */ - locale: { - arabic: Instabug.localeArabic, - chineseSimplified: Instabug.localeChineseSimplified, - chineseTraditional: Instabug.localeChineseTraditional, - czech: Instabug.localeCzech, - danish: Instabug.localeDanish, - english: Instabug.localeEnglish, - french: Instabug.localeFrench, - german: Instabug.localeGerman, - italian: Instabug.localeItalian, - japanese: Instabug.localeJapanese, - polish: Instabug.localePolish, - portugueseBrazil: Instabug.localePortugueseBrazil, - russian: Instabug.localeRussian, - spanish: Instabug.localeSpanish, - swedish: Instabug.localeSwedish, - turkish: Instabug.localeTurkish - }, - /** - * The color theme of the different UI elements - * @readonly - * @enum {number} - */ - colorTheme: { - light: Instabug.colorThemeLight, - dark: Instabug.colorThemeDark - }, - /** - * Rectangle edges - * @readonly - * @enum {number} - */ - rectEdge: { - minX: Instabug.rectMinXEdge, - minY: Instabug.rectMinYEdge, - maxX: Instabug.rectMaxXEdge, - maxY: Instabug.rectMaxYEdge - }, - /** - * Instabug strings - * @readonly - * @enum {number} - */ - strings: { - shakeHint: Instabug.shakeHint, - swipeHint: Instabug.swipeHint, - edgeSwipeStartHint: Instabug.edgeSwipeStartHint, - startAlertText: Instabug.startAlertText, - invalidEmailMessage: Instabug.invalidEmailMessage, - invalidEmailTitle: Instabug.invalidEmailTitle, - invalidCommentMessage: Instabug.invalidCommentMessage, - invalidCommentTitle: Instabug.invalidCommentTitle, - invocationHeader: Instabug.invocationHeader, - talkToUs: Instabug.talkToUs, - reportBug: Instabug.reportBug, - reportFeedback: Instabug.reportFeedback, - emailFieldHint: Instabug.emailFieldHint, - commentFieldHintForBugReport: Instabug.commentFieldHintForBugReport, - commentFieldHintForFeedback: Instabug.commentFieldHintForFeedback, - addVideoMessage: Instabug.addVideoMessage, - addVoiceMessage: Instabug.addVoiceMessage, - addImageFromGallery: Instabug.addImageFromGallery, - addExtraScreenshot: Instabug.addExtraScreenshot, - audioRecordingPermissionDeniedTitle: Instabug.audioRecordingPermissionDeniedTitle, - audioRecordingPermissionDeniedMessage: Instabug.audioRecordingPermissionDeniedMessage, - microphonePermissionAlertSettingsButtonText: Instabug.microphonePermissionAlertSettingsButtonText, - recordingMessageToHoldText: Instabug.recordingMessageToHoldText, - recordingMessageToReleaseText: Instabug.recordingMessageToReleaseText, - conversationsHeaderTitle: Instabug.conversationsHeaderTitle, - screenshotHeaderTitle: Instabug.screenshotHeaderTitle, - chatsNoConversationsHeadlineText: Instabug.chatsNoConversationsHeadlineText, - doneButtonText: Instabug.doneButtonText, - okButtonText: Instabug.okButtonText, - cancelButtonText: Instabug.cancelButtonText, - thankYouText: Instabug.thankYouText, - audio: Instabug.audio, - video: Instabug.video, - image: Instabug.image, - chatsHeaderTitle: Instabug.chatsHeaderTitle, - team: Instabug.team, - messageNotification: Instabug.messageNotification, - messagesNotifiactionAndOthers: Instabug.messagesNotifiactionAndOthers - } + /** + * Starts the SDK. + * This is the main SDK method that does all the magic. This is the only + * method that SHOULD be called. + * Should be called in constructor of the app registery component + * @param {string} token The token that identifies the app, you can find + * it on your dashboard. + * @param {invocationEvent} invocationEvent The event that invokes + * the SDK's UI. + */ + startWithToken: function (token, invocationEvent) { + Instabug.startWithToken(token, invocationEvent); + }, + + /** + * Invokes the SDK manually with the default invocation mode. + * Shows a view that asks the user whether they want to start a chat, report + * a problem or suggest an improvement. + */ + invoke: function () { + Instabug.invoke(); + }, + + /** + * Invokes the SDK with a specific mode. + * Invokes the SDK and show a specific view, instead of showing a prompt for + * users to choose from. + * @param {invocationMode} invocationMode Specifies which mode the + * SDK is going to start with. + */ + invokeWithInvocationMode: function (invocationMode) { + Instabug.invokeWithInvocationMode(invocationMode); + }, + + /** + * Dismisses any Instabug views that are currently being shown. + */ + dismiss: function () { + Instabug.dismiss(); + }, + + /** + * Attaches a file to each report being sent. + * A new copy of the file at fileLocation will be attached with each bug + * report being sent. + * Each call to this method overrides the file to be attached. + * The file has to be available locally at the provided path. + * @param {string} fileLocation Path to a file that's going to be attached + * to each report. + */ + // Not yet tested + setFileAttachment: function (fileLocation) { + Instabug.setFileAttachment(fileLocation); + }, + + /** + * Attaches user data to each report being sent. + * Each call to this method overrides the user data to be attached. + * Maximum size of the string is 1,000 characters. + * @param {string} userData A string to be attached to each report, with a + * maximum size of 1,000 characters. + */ + setUserData: function (userData) { + Instabug.setUserData(userData); + }, + + /** + * Adds custom logs that will be sent with each report. + * @param {string} log Message to be logged. + */ + IBGLog: function (log) { + Instabug.IBGLog(log); + }, + + /** + * Sets whether the SDK is tracking user steps or not. + * Enabling user steps would give you an insight on the scenario a user has + * performed before encountering a bug or a crash. User steps are attached + * with each report being sent. + * @param {boolean} isUserStepsEnabled A boolean to set user steps tracking + * to being enabled or disabled. + */ + setUserStepsEnabled: function (isUserStepsEnabled) { + Instabug.setUserStepsEnabled(isUserStepsEnabled); + }, + + /** + * A callback that gets executed before sending each bug report. + * @callback preSendingHandler + */ + + /** + * Sets a block of code to be executed before sending each report. + * This block is executed in the background before sending each report. Could + * be used for attaching logs and extra data to reports. + * @param {preSendingHandler} preSendingHandler - A callback that gets executed before sending each bug + * report. + */ + setPreSendingHandler: function (preSendingHandler) { + Instabug.addListener('IBGpreSendingHandler'); + NativeAppEventEmitter.addListener( + 'IBGpreSendingHandler', + preSendingHandler + ); + + Instabug.setPreSendingHandler(preSendingHandler); + }, + + /** + * Sets a block of code to be executed just before the SDK's UI is presented. + * This block is executed on the UI thread. Could be used for performing any + * UI changes before the SDK's UI is shown. + * @callback preSendingHandler + */ + + /** + * Sets a block of code to be executed just before the SDK's UI is presented. + * This block is executed on the UI thread. Could be used for performing any + * UI changes before the SDK's UI is shown. + * @param {preInvocationHandler} preInvocationHandler - A callback that gets executed before invoking the SDK + */ + setPreInvocationHandler: function (preInvocationHandler) { + Instabug.addListener('IBGpreInvocationHandler'); + NativeAppEventEmitter.addListener( + 'IBGpreInvocationHandler', + preInvocationHandler + ); + + Instabug.setPreInvocationHandler(preInvocationHandler); + }, + + /** + * A callback that gets executed after the SDK's UI is dismissed. + * @callback postInvocationHandler + * @param {dismissType} dismissType How the SDK was dismissed. + * @param {reportType} reportType Type of report that has been sent. Will be set + * to IBGReportTypeBug in case the SDK has been dismissed without selecting a + * report type, so you might need to check issueState before reportType + */ + + /** + * Sets a block of code to be executed right after the SDK's UI is dismissed. + * This block is executed on the UI thread. Could be used for performing any + * UI changes after the SDK's UI is dismissed. + * @param {postInvocationHandler} postInvocationHandler - A callback to get executed after + * dismissing the SDK. + */ + setPostInvocationHandler: function (postInvocationHandler) { + Instabug.addListener('IBGpostInvocationHandler'); + NativeAppEventEmitter.addListener( + 'IBGpostInvocationHandler', + function (payload) { + postInvocationHandler(payload['dismissType'], payload['reportType']); + } + ); + + Instabug.setPostInvocationHandler(postInvocationHandler); + }, + + /** + * Present a view that educates the user on how to invoke the SDK with the + * currently set invocation event. + */ + showIntroMessage: function () { + Instabug.showIntroMessage(); + }, + + /** + * Sets the default value of the user's email and hides the email field + * from the reporting UI. + * Defaults to an empty string. + * @param {string} userEmail An email address to be set as the user's email. + */ + setUserEmail: function (userEmail) { + Instabug.setUserEmail(userEmail); + }, + + /** + * Sets the default value of the user's name to be included with all reports. + * Defaults to an empty string. + * @param {string} userName Name of the user to be set. + */ + setUserName: function (userName) { + Instabug.setUserName(userName); + }, + + /** + * Enables/disables screenshot view when reporting a bug/improvement. + * By default, screenshot view is shown when reporting a bug, but not when + * sending feedback. + * @param {boolean} willSkipScreenshotAnnotation sets whether screenshot view is + * shown or not. Passing YES will show screenshot view for both feedback and + * bug reporting, while passing NO will disable it for both. + */ + setWillSkipScreenshotAnnotation: function (willSkipScreenshotAnnotation) { + Instabug.setWillSkipScreenshotAnnotation(willSkipScreenshotAnnotation); + }, + + /** + * return callback + * @callback messageCountCallback + * @param{number} responseCount Notifications count, or -1 incase the SDK has + * not been initialized. + */ + + /** + * Returns the number of unread messages the user currently has. + * Use this method to get the number of unread messages the user + * has, then possibly notify them about it with your own UI. + * @param {messageCountCallback} messageCountCallback callback with argument + * Notifications count, or -1 incase the SDK has not been initialized. + */ + getUnreadMessagesCount: function (messageCountCallback) { + Instabug.getUnreadMessagesCount(messageCountCallback); + }, + + /** + * Sets the event that invoke the feedback form. + * Default is set by `Instabug.startWithToken`. + * @param {invocationEvent} invocationEvent Event that invokes the + * feedback form. + */ + setInvocationEvent: function (invocationEvent) { + Instabug.setInvocationEvent(invocationEvent); + }, + + /** + * Enables/disables the use of push notifications in the SDK. + * Defaults to YES. + * @param {boolean} isPushNotificationEnabled A boolean to indicate whether push + * notifications are enabled or disabled. + */ + setPushNotificationsEnabled: function (isPushNotificationEnabled) { + Instabug.setPushNotificationsEnabled(isPushNotificationEnabled); + }, + + /** + * Sets whether users are required to enter an email address or not when + * sending reports. + * Defaults to YES. + * @param {boolean} isEmailFieldRequired A boolean to indicate whether email + * field is required or not. + */ + setEmailFieldRequired: function (isEmailFieldRequired) { + Instabug.setEmailFieldRequired(isEmailFieldRequired); + }, + + /** + * Sets whether users are required to enter a comment or not when sending reports. + * Defaults to NO. + * @param {boolean} isCommentFieldRequired A boolean to indicate whether comment + * field is required or not. + */ + setCommentFieldRequired: function (isCommentFieldRequired) { + Instabug.setCommentFieldRequired(isCommentFieldRequired); + }, + + /** + * Sets the threshold value of the shake gesture for iPhone/iPod Touch and iPad. + * Default for iPhone is 2.5. + * Default for iPad is 0.6. + * @param {number} iPhoneShakingThreshold Threshold for iPhone. + * @param {number} iPadShakingThreshold Threshold for iPad. + */ + setShakingThresholdForIPhone: function (iPhoneShakingThreshold, iPadShakingThreshold) { + Instabug.setShakingThresholdForIPhone(iPhoneShakingThreshold, iPadShakingThreshold); + }, + + /** + * Sets the default edge and offset from the top at which the floating button + * will be shown. Different orientations are already handled. + * Default for `floatingButtonEdge` is `rectEdge.maxX`. + * Default for `floatingButtonOffsetFromTop` is 50 + * @param {rectEdge} floatingButtonEdge `maxX` to show on the right, + * or `minX` to show on the left. + * @param {number} offsetFromTop floatingButtonOffsetFromTop Top offset for + * floating button. + */ + setFloatingButtonEdge: function (floatingButtonEdge, offsetFromTop) { + Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop); + }, + + /** + * Sets the SDK's locale. + * Use to change the SDK's UI to different language. + * Defaults to the device's current locale. + * @param {locale} locale A locale to set the SDK to. + */ + setLocale: function (locale) { + if (Platform.OS === 'ios') { + Instabug.setLocale(locale); + } else if (Platform.OS === 'android') { + Instabug.changeLocale(locale); + } + }, + + /** + * Sets whether the intro message that gets shown on launching the app is + * enabled or not. + * Defaults to YES. + * @param {boolean} isIntroMessageEnabled A boolean to indicate whether the + * intro message is enabled or not. + */ + setIntroMessageEnabled: function (isIntroMessageEnabled) { + Instabug.setIntroMessageEnabled(isIntroMessageEnabled); + }, + + /** + * Sets the color theme of the SDK's whole UI. + * the SDK's UI to. + * @param colorTheme + */ + setColorTheme: function (colorTheme) { + Instabug.setColorTheme(colorTheme); + }, + + /** + * Sets the primary color of the SDK's UI. + * Sets the color of UI elements indicating interactivity or call to action. + * To use, import processColor and pass to it with argument the color hex + * as argument. + * @param {color} primaryColor A color to set the UI elements of the SDK to. + */ + setPrimaryColor: function (primaryColor) { + Instabug.setPrimaryColor(primaryColor); + }, + + /** + * Appends a set of tags to previously added tags of reported feedback, + * bug or crash. + * @param {string[]} tags An array of tags to append to current tags. + */ + appendTags: function (tags) { + Instabug.appendTags(tags); + }, + + /** + * Manually removes all tags of reported feedback, bug or crash. + */ + resetTags: function () { + Instabug.resetTags(); + }, + + /** + * return callback + * @callback tagsCallback + * @param {string[]} tags of reported feedback, bug or crash. + */ + + /** + * Gets all tags of reported feedback, bug or crash. + * @param {tagsCallback} tagsCallback callback with argument tags of reported feedback, bug or crash. + */ + getTags: function (tagsCallback) { + Instabug.getTags(tagsCallback); + }, + + /** + * Overrides any of the strings shown in the SDK with custom ones. + * Allows you to customize any of the strings shown to users in the SDK. + * @param {string} string String value to override the default one. + * @param {strings} key Key of string to override. + */ + setStringToKey: function (string, key) { + Instabug.setString(string, key); + }, + + /** + * Sets whether attachments in bug reporting and in-app messaging are enabled or not. + * @param {boolean} screenshot A boolean to enable or disable screenshot attachments. + * @param {boolean} extraScreenshot A boolean to enable or disable extra + * screenshot attachments. + * @param {boolean} galleryImage A boolean to enable or disable gallery image + * attachments. In iOS 10+,NSPhotoLibraryUsageDescription should be set in + * info.plist to enable gallery image attachments. + * @param {boolean} voiceNote A boolean to enable or disable voice note attachments. + * In iOS 10+, NSMicrophoneUsageDescription should be set in info.plist to enable + * voiceNote attachments. + * @param {boolean} screenRecording A boolean to enable or disable screen recording attachments. + */ + setAttachmentTypesEnabled: function (screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording) { + Instabug.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording); + }, + + /** + * Enables/disables showing in-app notifications when the user receives a + * new message. + * @param {boolean} isChatNotificationEnabled A boolean to set whether + * notifications are enabled or disabled. + */ + setChatNotificationEnabled: function (isChatNotificationEnabled) { + Instabug.setChatNotificationEnabled(isChatNotificationEnabled); + }, + + /** + * A callback that gets executed when a new message is received. + * @callback onNewMessgaeHandler + */ + + /** + * Sets a block of code that gets executed when a new message is received. + * @param {onNewMessgaeHandler} onNewMessageHandler - A callback that gets + * executed when a new message is received. + */ + setOnNewMessageHandler: function (onNewMessageHandler) { + Instabug.addListener('IBGonNewMessageHandler'); + NativeAppEventEmitter.addListener( + 'IBGonNewMessageHandler', + onNewMessgaeHandler + ); + + Instabug.setOnNewMessageHandler(onNewMessgaeHandler); + }, + + /** + * Enables/disables prompt options when SDK is invoked. + * When only a single option is enabled, it become the default invocation mode. + * If all options are disabled, bug reporting becomes the default invocation mode. + * By default, all three options are enabled. + * @param {boolean} isBugReportingEnabled A boolean to indicate whether bug reports + * are enabled or disabled. + * @param {boolean} isFeedbackReportingEnabled A boolean to indicate whether feedback is + * enabled or disabled. + * @param {boolean} isChatEnabled A boolean to indicate whether chat is enabled + * or disabled. + */ + setPromptOptions: function (isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled) { + Instabug.setPromptOptions(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled); + }, + + /** + * return callback + * @callback isInstabugNotificationCallback + * @param {boolean} isInstabugNotification + */ + + /** + * Checks if a notification is from Instabug. + * If you are using push notifications, use this method to check whether an + * incoming notification is from Instabug or not. If this method returns YES, + * you should call didReceiveRemoteNotification: to let the Instabug handle + * the notification. Otherwise, handle the notification on your own. + * @param {Object} dict Notification's userInfo + * @param {isInstabugNotificationCallback} isInstabugNotificationCallback callback with + * argument isInstabugNotification + */ + isInstabugNotification: function (dict, isInstabugNotificationCallback) { + Instabug.isInstabugNotification(dict, isInstabugNotificationCallback); + }, + + /** + * The event used to invoke the feedback form + * @readonly + * @enum {number} + */ + invocationEvent: { + none: Instabug.invocationEventNone, + shake: Instabug.invocationEventShake, + screenshot: Instabug.invocationEventScreenshot, + twoFingersSwipe: Instabug.invocationEventTwoFingersSwipe, + floatingButton: Instabug.invocationEventFloatingButton + }, + /** + * Type of SDK dismiss + * @readonly + * @enum {number} + */ + dismissType: { + submit: Instabug.dismissTypeSubmit, + cancel: Instabug.dismissTypeCancel, + addAttachment: Instabug.dismissTypeAddAttachment + }, + /** + * Type of report to be submit + * @readonly + * @enum {number} + */ + reportType: { + bug: Instabug.reportTypeBug, + feedback: Instabug.reportTypeFeedback + }, + /** + * The mode used upon invocating the SDK + * @readonly + * @enum {number} + */ + invocationMode: { + NA: Instabug.invocationModeNA, + newBug: Instabug.invocationModeNewBug, + newFeedback: Instabug.invocationModeNewFeedback, + newChat: Instabug.invocationModeNewChat, + chatsList: Instabug.invocationModeChatsList + }, + /** + * The supported locales + * @readonly + * @enum {number} + */ + locale: { + arabic: Instabug.localeArabic, + chineseSimplified: Instabug.localeChineseSimplified, + chineseTraditional: Instabug.localeChineseTraditional, + czech: Instabug.localeCzech, + danish: Instabug.localeDanish, + english: Instabug.localeEnglish, + french: Instabug.localeFrench, + german: Instabug.localeGerman, + italian: Instabug.localeItalian, + japanese: Instabug.localeJapanese, + polish: Instabug.localePolish, + portugueseBrazil: Instabug.localePortugueseBrazil, + russian: Instabug.localeRussian, + spanish: Instabug.localeSpanish, + swedish: Instabug.localeSwedish, + turkish: Instabug.localeTurkish + }, + /** + * The color theme of the different UI elements + * @readonly + * @enum {number} + */ + colorTheme: { + light: Instabug.colorThemeLight, + dark: Instabug.colorThemeDark + }, + /** + * Rectangle edges + * @readonly + * @enum {number} + */ + rectEdge: { + minX: Instabug.rectMinXEdge, + minY: Instabug.rectMinYEdge, + maxX: Instabug.rectMaxXEdge, + maxY: Instabug.rectMaxYEdge + }, + /** + * Instabug strings + * @readonly + * @enum {number} + */ + strings: { + shakeHint: Instabug.shakeHint, + swipeHint: Instabug.swipeHint, + edgeSwipeStartHint: Instabug.edgeSwipeStartHint, + startAlertText: Instabug.startAlertText, + invalidEmailMessage: Instabug.invalidEmailMessage, + invalidEmailTitle: Instabug.invalidEmailTitle, + invalidCommentMessage: Instabug.invalidCommentMessage, + invalidCommentTitle: Instabug.invalidCommentTitle, + invocationHeader: Instabug.invocationHeader, + talkToUs: Instabug.talkToUs, + reportBug: Instabug.reportBug, + reportFeedback: Instabug.reportFeedback, + emailFieldHint: Instabug.emailFieldHint, + commentFieldHintForBugReport: Instabug.commentFieldHintForBugReport, + commentFieldHintForFeedback: Instabug.commentFieldHintForFeedback, + addVideoMessage: Instabug.addVideoMessage, + addVoiceMessage: Instabug.addVoiceMessage, + addImageFromGallery: Instabug.addImageFromGallery, + addExtraScreenshot: Instabug.addExtraScreenshot, + audioRecordingPermissionDeniedTitle: Instabug.audioRecordingPermissionDeniedTitle, + audioRecordingPermissionDeniedMessage: Instabug.audioRecordingPermissionDeniedMessage, + microphonePermissionAlertSettingsButtonText: Instabug.microphonePermissionAlertSettingsButtonText, + recordingMessageToHoldText: Instabug.recordingMessageToHoldText, + recordingMessageToReleaseText: Instabug.recordingMessageToReleaseText, + conversationsHeaderTitle: Instabug.conversationsHeaderTitle, + screenshotHeaderTitle: Instabug.screenshotHeaderTitle, + chatsNoConversationsHeadlineText: Instabug.chatsNoConversationsHeadlineText, + doneButtonText: Instabug.doneButtonText, + okButtonText: Instabug.okButtonText, + cancelButtonText: Instabug.cancelButtonText, + thankYouText: Instabug.thankYouText, + audio: Instabug.audio, + video: Instabug.video, + image: Instabug.image, + chatsHeaderTitle: Instabug.chatsHeaderTitle, + team: Instabug.team, + messageNotification: Instabug.messageNotification, + messagesNotificationAndOthers: Instabug.messagesNotificationAndOthers + } } \ No newline at end of file diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 447b6db2e..97f202168 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -127,8 +127,8 @@ - (dispatch_queue_t)methodQueue { [Instabug setCommentFieldRequired:isCommentFieldRequired]; } -RCT_EXPORT_METHOD(setShakingThresholdForiPhone:(double)iPhoneShakingThreshold foriPad:(double)iPadShakingThreshold) { - [Instabug setShakingThresholdForiPhone:iPhoneShakingThreshold foriPad:iPadShakingThreshold]; +RCT_EXPORT_METHOD(setShakingThresholdForIPhone:(double)iPhoneShakingThreshold forIPad:(double)iPadShakingThreshold) { + [Instabug setShakingThresholdForIPhone:iPhoneShakingThreshold forIPad:iPadShakingThreshold]; } RCT_EXPORT_METHOD(setFloatingButtonEdge:(CGRectEdge)floatingButtonEdge withTopOffset:(double)floatingButtonOffsetFromTop) { diff --git a/package.json b/package.json index 6650c5e4b..cb6333cc4 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,3 @@ - { "name": "instabug-reactnative", "version": "1.0.5", @@ -6,13 +5,13 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { + }, + "repository": { "type": "git", "url": "git+https://github.com/Instabug/instabug-reactnative.git" }, "keywords": [ - "react-native", + "react-native", "bug", "reporting", "feedback", @@ -21,7 +20,7 @@ ], "author": "Hossam Hassan && Yousef Hamza", "license": "MIT", - "bugs": { + "bugs": { "url": "https://github.com/Instabug/instabug-reactnative/issues" }, "homepage": "https://github.com/Instabug/instabug-reactnative#readme",