22 NativeModules ,
33 NativeAppEventEmitter ,
44 DeviceEventEmitter ,
5- Platform
5+ Platform ,
6+ processColor
67} from 'react-native' ;
78let { Instabug } = NativeModules ;
89import InstabugUtils from './utils/InstabugUtils' ;
@@ -89,6 +90,15 @@ const InstabugModule = {
8990 Instabug . setIBGLogPrintsToConsole ( printsToConsole ) ;
9091 } ,
9192
93+ /**
94+ * @deprecated use {@link CrashReporting.setCrashReportingEnabled}
95+ * Report un-caught exceptions to Instabug dashboard
96+ * We don't send exceptions from __DEV__, since it's way too noisy!
97+ */
98+ setCrashReportingEnabled : function ( enableCrashReporter ) {
99+ Instabug . setCrashReportingEnabled ( enableCrashReporter ) ;
100+ } ,
101+
92102 /**
93103 * Sets a block of code to be executed when a prompt option is selected.
94104 * @param {function } didSelectPromptOptionHandler - A block of code that
@@ -125,6 +135,19 @@ const InstabugModule = {
125135 Instabug . setSessionProfilerEnabled ( sessionProfilerEnabled ) ;
126136 } ,
127137
138+ /**
139+ * @deprecated use {@link Replies.getUnreadRepliesCount}
140+ * Returns the number of unread messages the user currently has.
141+ * Use this method to get the number of unread messages the user
142+ * has, then possibly notify them about it with your own UI.
143+ * @param {messageCountCallback } messageCountCallback callback with argument
144+ * Notifications count, or -1 in case the SDK has not been initialized.
145+ */
146+
147+ getUnreadMessagesCount : function ( messageCountCallback ) {
148+ Instabug . getUnreadMessagesCount ( messageCountCallback ) ;
149+ } ,
150+
128151 /**
129152 * Enables/disables the use of push notifications in the SDK.
130153 * Defaults to YES.
@@ -197,7 +220,7 @@ const InstabugModule = {
197220 * @param {color } primaryColor A color to set the UI elements of the SDK to.
198221 */
199222 setPrimaryColor : function ( primaryColor ) {
200- Instabug . setPrimaryColor ( primaryColor ) ;
223+ Instabug . setPrimaryColor ( primaryColor ) ;
201224 } ,
202225
203226 /**
@@ -471,6 +494,42 @@ const InstabugModule = {
471494 Instabug . clearAllUserAttributes ( ) ;
472495 } ,
473496
497+ /**
498+ * @deprecated use {@link Replies.setInAppNotificationsEnabled}
499+ * Enables/disables showing in-app notifications when the user receives a
500+ * new message.
501+ * @param {boolean } isChatNotificationEnabled A boolean to set whether
502+ * notifications are enabled or disabled.
503+ */
504+
505+ setChatNotificationEnabled : function ( isChatNotificationEnabled ) {
506+ Instabug . setChatNotificationEnabled ( isChatNotificationEnabled ) ;
507+ } ,
508+
509+ /**
510+ * @deprecated use {@link Replies.setOnNewReplyReceivedCallback}
511+ * Sets a block of code that gets executed when a new message is received.
512+ * @param {function } onNewMessageHandler - A callback that gets
513+ * executed when a new message is received.
514+ */
515+
516+ setOnNewMessageHandler : function ( onNewMessageHandler ) {
517+ if ( Platform . OS === 'ios' ) {
518+ Instabug . addListener ( 'IBGonNewMessageHandler' ) ;
519+ NativeAppEventEmitter . addListener (
520+ 'IBGonNewMessageHandler' ,
521+ onNewMessageHandler
522+ ) ;
523+ } else {
524+ DeviceEventEmitter . addListener (
525+ 'IBGonNewMessageHandler' ,
526+ onNewMessageHandler
527+ ) ;
528+ }
529+
530+ Instabug . setOnNewMessageHandler ( onNewMessageHandler ) ;
531+ } ,
532+
474533 /**
475534 * @summary Enables/disables inspect view hierarchy when reporting a bug/feedback.
476535 * @param {boolean } viewHierarchyEnabled A boolean to set whether view hierarchy are enabled
@@ -480,6 +539,21 @@ const InstabugModule = {
480539 Instabug . setViewHierarchyEnabled ( viewHierarchyEnabled ) ;
481540 } ,
482541
542+ /**
543+ * @deprecated use {@link Surveys.setEnabled}
544+ * @summary Sets whether surveys are enabled or not.
545+ * If you disable surveys on the SDK but still have active surveys on your Instabug dashboard,
546+ * those surveys are still going to be sent to the device, but are not going to be
547+ * shown automatically.
548+ * To manually display any available surveys, call `Instabug.showSurveyIfAvailable()`.
549+ * Defaults to `true`.
550+ * @param {boolean } surveysEnabled A boolean to set whether Instabug Surveys is enabled or disabled.
551+ */
552+
553+ setSurveysEnabled : function ( surveysEnabled ) {
554+ Instabug . setSurveysEnabled ( surveysEnabled ) ;
555+ } ,
556+
483557 /**
484558 * Enable/Disable debug logs from Instabug SDK
485559 * Default state: disabled
@@ -512,6 +586,43 @@ const InstabugModule = {
512586 }
513587 } ,
514588
589+ /**
590+ * @deprecated use {@link Replies.setInAppNotificationSound}
591+ * Set whether new in app notification received will play a small sound notification
592+ * or not (Default is {@code false})
593+ *
594+ * @param shouldPlaySound desired state of conversation sounds
595+ * @since 4.1.0
596+ */
597+
598+ setEnableInAppNotificationSound : function ( shouldPlaySound ) {
599+ if ( Platform . OS === 'android' ) {
600+ Instabug . setEnableInAppNotificationSound ( shouldPlaySound ) ;
601+ }
602+ } ,
603+
604+ /**
605+ * @deprecated use {@link CrashReporting.reportJSException}
606+ * Send handled JS error object
607+ *
608+ * @param errorObject Error object to be sent to Instabug's servers
609+ */
610+
611+ reportJSException : function ( errorObject ) {
612+ let jsStackTrace = InstabugUtils . parseErrorStack ( errorObject ) ;
613+ var jsonObject = {
614+ message : errorObject . name + ' - ' + errorObject . message ,
615+ os : Platform . OS ,
616+ platform : 'react_native' ,
617+ exception : jsStackTrace
618+ } ;
619+ if ( Platform . OS === 'android' ) {
620+ Instabug . sendHandledJSCrash ( JSON . stringify ( jsonObject ) ) ;
621+ } else {
622+ Instabug . sendHandledJSCrash ( jsonObject ) ;
623+ }
624+ } ,
625+
515626 /**
516627 * @summary Checks whether app is development/Beta testing OR live
517628 * Note: This API is iOS only
0 commit comments