77#import " InstabugReactBridge.h"
88#import < Instabug/Instabug.h>
99#import < Instabug/IBGBugReporting.h>
10+ #import < Instabug/IBGCrashReporting.h>
11+ #import < Instabug/IBGLog.h>
1012#import < asl.h>
1113#import < React/RCTLog.h>
1214#import < os/log.h>
@@ -21,7 +23,8 @@ @implementation InstabugReactBridge
2123 @" IBGpostInvocationHandler" ,
2224 @" IBGonNewMessageHandler" ,
2325 @" IBGWillShowSurvey" ,
24- @" IBGDidDismissSurvey"
26+ @" IBGDidDismissSurvey" ,
27+ @" IBGDidSelectPromptOptionHandler"
2528 ];
2629}
2730
@@ -39,7 +42,7 @@ - (dispatch_queue_t)methodQueue {
3942 [Instabug startWithToken: token invocationEvents: invocationEvents];
4043 RCTAddLogFunction (InstabugReactLogFunction);
4144 RCTSetLogThreshold (RCTLogLevelInfo);
42- [Instabug setNetworkLoggingEnabled: NO ];
45+ [IBGNetworkLogger.enabled = NO ];
4346 SEL setCrossPlatformSEL = NSSelectorFromString (@" setCrossPlatform:" );
4447 if ([[Instabug class ] respondsToSelector: setCrossPlatformSEL]) {
4548 [[Instabug class ] performSelector: setCrossPlatformSEL withObject: @(true )];
@@ -89,7 +92,7 @@ - (dispatch_queue_t)methodQueue {
8992}
9093
9194RCT_EXPORT_METHOD (IBGLog:(NSString *)log) {
92- [Instabug IBGLog: log];
95+ [IBGLog log : log];
9396}
9497
9598RCT_EXPORT_METHOD (showSurveyWithToken:(NSString *)surveyToken) {
@@ -106,50 +109,62 @@ - (dispatch_queue_t)methodQueue {
106109
107110RCT_EXPORT_METHOD (setCrashReportingEnabled:(BOOL )enabledCrashReporter) {
108111 if (enabledCrashReporter) {
109- [Instabug setCrashReportingEnabled: YES ] ;
112+ IBGCrashReporting. enabled = YES ;
110113 } else {
111- [Instabug setCrashReportingEnabled: NO ] ;
114+ IBGCrashReporting. enabled = NO ;
112115 }
113116}
114117
115118RCT_EXPORT_METHOD (setAutoScreenRecordingEnabled:(BOOL )enabled) {
116- [ Instabug setAutoScreenRecordingEnabled: enabled] ;
119+ Instabug. autoScreenRecordingEnabled = enabled;
117120}
118121
119122RCT_EXPORT_METHOD (setAutoScreenRecordingMaxDuration:(CGFloat)duration) {
120- [ Instabug setAutoScreenRecordingDuration: duration] ;
123+ Instabug. autoScreenRecordingDuration = duration;
121124}
122125
123126RCT_EXPORT_METHOD (setPreSendingHandler:(RCTResponseSenderBlock)callBack) {
124127 if (callBack != nil ) {
125- [Instabug setPreSendingHandler: ^{
128+ IBGBugReporting. willSendReportHandler = ^{
126129 [self sendEventWithName: @" IBGpreSendingHandler" body: nil ];
127- }] ;
130+ };
128131 } else {
129- [Instabug setPreSendingHandler: nil ] ;
132+ IBGBugReporting. willSendReportHandler = nil ;
130133 }
131134}
132135
133136RCT_EXPORT_METHOD (setPreInvocationHandler:(RCTResponseSenderBlock)callBack) {
134137 if (callBack != nil ) {
135- [Instabug setPreInvocationHandler: ^{
138+ IBGBugReporting. willInvokeHandler = ^{
136139 [self sendEventWithName: @" IBGpreInvocationHandler" body: nil ];
137- }] ;
140+ };
138141 } else {
139- [Instabug setPreInvocationHandler: nil ] ;
142+ IBGBugReporting. willInvokeHandler = nil ;
140143 }
141144}
142145
143146RCT_EXPORT_METHOD (setPostInvocationHandler:(RCTResponseSenderBlock)callBack) {
144147 if (callBack != nil ) {
145- [Instabug setPostInvocationHandler: ^(IBGDismissType dismissType, IBGReportType reportType) {
148+ IBGBugReporting. didDismissHandler = ^(IBGDismissType dismissType, IBGReportType reportType) {
146149 [self sendEventWithName: @" IBGpostInvocationHandler" body: @{
147150 @" dismissType" : @(dismissType),
148151 @" reportType" : @(reportType)
149152 }];
150- }];
153+ };
154+ } else {
155+ IBGBugReporting.didDismissHandler = nil ;
156+ }
157+ }
158+
159+ RCT_EXPORT_METHOD (didSelectPromptOptionHandler:(RCTResponseSenderBlock)callBack) {
160+ if (callBack != nil ) {
161+ IBGBugReporting.didSelectPromptOptionHandler = ^(IBGPromptOption promptOption) {
162+ [self sendEventWithName: @" IBGDidSelectPromptOptionHandler" body: @{
163+ @" promptOption" : @(promptOption)
164+ }];
165+ };
151166 } else {
152- [Instabug setPostInvocationHandler: nil ] ;
167+ IBGBugReporting. didSelectPromptOptionHandler = nil ;
153168 }
154169}
155170
@@ -170,13 +185,21 @@ - (dispatch_queue_t)methodQueue {
170185}
171186
172187RCT_EXPORT_METHOD (getUnreadMessagesCount:(RCTResponseSenderBlock)callBack) {
173- callBack (@[@([ Instabug getUnreadMessagesCount ] )]);
188+ callBack (@[@(Instabug.unreadMessagesCount )]);
174189}
175190
176191RCT_EXPORT_METHOD (setInvocationEvent:(IBGInvocationEvent)invocationEvent) {
177192 [Instabug setInvocationEvent: invocationEvent];
178193}
179194
195+ RCT_EXPORT_METHOD (setInvocationEvents:(NSArray *)invocationEventsArray) {
196+ IBGInvocationEvent invocationEvents = 0 ;
197+ for (NSNumber *boxedValue in invocationEventsArray) {
198+ invocationEvents |= [boxedValue intValue ];
199+ }
200+ IBGBugReporting.invocationEvents = invocationEvents;
201+ }
202+
180203RCT_EXPORT_METHOD (setPushNotificationsEnabled:(BOOL )isPushNotificationEnabled) {
181204 [Instabug setPushNotificationsEnabled: isPushNotificationEnabled];
182205}
@@ -194,28 +217,37 @@ - (dispatch_queue_t)methodQueue {
194217 foriPad: iPadShakingThreshold];
195218}
196219
220+ RCT_EXPORT_METHOD (setShakingThresholdForiPhone:(double )iPhoneShakingThreshold) {
221+ IBGBugReporting.shakingThresholdForiPhone = iPhoneShakingThreshold;
222+ }
223+
224+ RCT_EXPORT_METHOD (setShakingThresholdForiPad:(double )iPadShakingThreshold) {
225+ IBGBugReporting.shakingThresholdForiPad = iPadShakingThreshold;
226+ }
227+
197228RCT_EXPORT_METHOD (setFloatingButtonEdge:(CGRectEdge)floatingButtonEdge withTopOffset:(double )floatingButtonOffsetFromTop) {
198- [Instabug setFloatingButtonEdge: floatingButtonEdge withTopOffset: floatingButtonOffsetFromTop];
229+ IBGBugReporting.floatingButtonEdge = floatingButtonEdge;
230+ IBGBugReporting.floatingButtonTopOffset = floatingButtonOffsetFromTop;
199231}
200232
201233RCT_EXPORT_METHOD (setLocale:(IBGLocale)locale) {
202234 [Instabug setLocale: locale];
203235}
204236
205237RCT_EXPORT_METHOD (setExtendedBugReportMode:(IBGExtendedBugReportMode)extendedBugReportMode) {
206- [Instabug setExtendedBugReportMode: extendedBugReportMode] ;
238+ IBGBugReporting. extendedBugReportMode = extendedBugReportMode;
207239}
208240
209241RCT_EXPORT_METHOD (setIntroMessageEnabled:(BOOL )isIntroMessageEnabled) {
210- [Instabug setIntroMessageEnabled: isIntroMessageEnabled] ;
242+ IBGBugReporting. introMessageEnabled = isIntroMessageEnabled;
211243}
212244
213245RCT_EXPORT_METHOD (setColorTheme:(IBGColorTheme)colorTheme) {
214246 [Instabug setColorTheme: colorTheme];
215247}
216248
217249RCT_EXPORT_METHOD (setPrimaryColor:(UIColor *)color) {
218- [ Instabug setPrimaryColor: color] ;
250+ Instabug. tintColor = color;
219251}
220252
221253RCT_EXPORT_METHOD (appendTags:(NSArray *)tags) {
@@ -252,20 +284,20 @@ - (dispatch_queue_t)methodQueue {
252284 attachmentTypes |= IBGAttachmentTypeScreenRecording;
253285 }
254286
255- [Instabug setEnabledAttachmentTypes: attachmentTypes] ;
287+ IBGBugReporting. enabledAttachmentTypes = attachmentTypes;
256288 }
257289
258290RCT_EXPORT_METHOD (setChatNotificationEnabled:(BOOL )isChatNotificationEnabled) {
259- [ Instabug setChatNotificationEnabled: isChatNotificationEnabled] ;
291+ Instabug. replyNotificationsEnabled = isChatNotificationEnabled;
260292}
261293
262294RCT_EXPORT_METHOD (setOnNewMessageHandler:(RCTResponseSenderBlock)callBack) {
263295 if (callBack != nil ) {
264- [ Instabug setOnNewMessageHandler: ^{
296+ Instabug. didRecieveReplyHandler = ^{
265297 [self sendEventWithName: @" IBGonNewMessageHandler" body: nil ];
266- }] ;
298+ };
267299 } else {
268- [ Instabug setOnNewMessageHandler: nil ] ;
300+ Instabug. didRecieveReplyHandler = nil ;
269301 }
270302}
271303
@@ -332,7 +364,7 @@ - (dispatch_queue_t)methodQueue {
332364}
333365
334366RCT_EXPORT_METHOD (setViewHierarchyEnabled:(BOOL )viewHierarchyEnabled) {
335- [ Instabug setViewHierarchyEnabled: viewHierarchyEnabled] ;
367+ Instabug. shouldCaptureViewHierarchy = viewHierarchyEnabled;
336368}
337369
338370RCT_EXPORT_METHOD (logUserEventWithName:(NSString *)name) {
@@ -343,28 +375,28 @@ - (dispatch_queue_t)methodQueue {
343375 [Instabug logUserEventWithName: name params: params];
344376}
345377
346- RCT_EXPORT_METHOD (log:( NSString *)log ) {
347- [Instabug IBGLog: log] ;
378+ RCT_EXPORT_METHOD (setIBGLogPrintsToConsole:( BOOL ) printsToConsole ) {
379+ IBGLog. printsToConsole = printsToConsole ;
348380}
349381
350382RCT_EXPORT_METHOD (logVerbose:(NSString *)log) {
351- [Instabug logVerbose: log];
383+ [IBGLog logVerbose: log];
352384}
353385
354386RCT_EXPORT_METHOD (logDebug:(NSString *)log) {
355- [Instabug logDebug: log];
387+ [IBGLog logDebug: log];
356388}
357389
358390RCT_EXPORT_METHOD (logInfo:(NSString *)log) {
359- [Instabug logInfo: log];
391+ [IBGLog logInfo: log];
360392}
361393
362394RCT_EXPORT_METHOD (logWarn:(NSString *)log) {
363- [Instabug logWarn: log];
395+ [IBGLog logWarn: log];
364396}
365397
366398RCT_EXPORT_METHOD (logError:(NSString *)log) {
367- [Instabug logError: log];
399+ [IBGLog logError: log];
368400}
369401
370402RCT_EXPORT_METHOD (setSurveysEnabled:(BOOL )surveysEnabled) {
@@ -404,7 +436,7 @@ - (dispatch_queue_t)methodQueue {
404436}
405437
406438RCT_EXPORT_METHOD (setVideoRecordingFloatingButtonPosition:(IBGPosition)position) {
407- [Instabug setVideoRecordingFloatingButtonPosition: position] ;
439+ IBGBugReporting. videoRecordingFloatingButtonPosition = position;
408440}
409441
410442RCT_EXPORT_METHOD (setThresholdForReshowingSurveyAfterDismiss:(NSInteger )sessionCount daysCount:(NSInteger )daysCount) {
@@ -416,7 +448,7 @@ - (dispatch_queue_t)methodQueue {
416448}
417449
418450RCT_EXPORT_METHOD (showFeatureRequests) {
419- [Instabug showFeatureRequests ];
451+ [IBGFeatureRequests show ];
420452}
421453
422454RCT_EXPORT_METHOD (setShouldShowSurveysWelcomeScreen:(BOOL )shouldShowWelcomeScreen) {
@@ -431,7 +463,7 @@ - (dispatch_queue_t)methodQueue {
431463 actionTypes |= [boxedValue intValue ];
432464 }
433465
434- [Instabug setEmailFieldRequired: isEmailFieldRequired forAction: actionTypes];
466+ [IBGFeatureRequests setEmailFieldRequired: isEmailFieldRequired forAction: actionTypes];
435467 }
436468
437469RCT_EXPORT_METHOD (isRunningLive:(RCTResponseSenderBlock)callback) {
0 commit comments