7
7
#import " InstabugReactBridge.h"
8
8
#import < Instabug/Instabug.h>
9
9
#import < Instabug/IBGBugReporting.h>
10
+ #import < Instabug/IBGCrashReporting.h>
11
+ #import < Instabug/IBGLog.h>
10
12
#import < asl.h>
11
13
#import < React/RCTLog.h>
12
14
#import < os/log.h>
@@ -21,7 +23,8 @@ @implementation InstabugReactBridge
21
23
@" IBGpostInvocationHandler" ,
22
24
@" IBGonNewMessageHandler" ,
23
25
@" IBGWillShowSurvey" ,
24
- @" IBGDidDismissSurvey"
26
+ @" IBGDidDismissSurvey" ,
27
+ @" IBGDidSelectPromptOptionHandler"
25
28
];
26
29
}
27
30
@@ -39,7 +42,7 @@ - (dispatch_queue_t)methodQueue {
39
42
[Instabug startWithToken: token invocationEvents: invocationEvents];
40
43
RCTAddLogFunction (InstabugReactLogFunction);
41
44
RCTSetLogThreshold (RCTLogLevelInfo);
42
- [Instabug setNetworkLoggingEnabled: NO ];
45
+ [IBGNetworkLogger.enabled = NO ];
43
46
SEL setCrossPlatformSEL = NSSelectorFromString (@" setCrossPlatform:" );
44
47
if ([[Instabug class ] respondsToSelector: setCrossPlatformSEL]) {
45
48
[[Instabug class ] performSelector: setCrossPlatformSEL withObject: @(true )];
@@ -89,7 +92,7 @@ - (dispatch_queue_t)methodQueue {
89
92
}
90
93
91
94
RCT_EXPORT_METHOD (IBGLog:(NSString *)log) {
92
- [Instabug IBGLog: log];
95
+ [IBGLog log : log];
93
96
}
94
97
95
98
RCT_EXPORT_METHOD (showSurveyWithToken:(NSString *)surveyToken) {
@@ -106,50 +109,62 @@ - (dispatch_queue_t)methodQueue {
106
109
107
110
RCT_EXPORT_METHOD (setCrashReportingEnabled:(BOOL )enabledCrashReporter) {
108
111
if (enabledCrashReporter) {
109
- [Instabug setCrashReportingEnabled: YES ] ;
112
+ IBGCrashReporting. enabled = YES ;
110
113
} else {
111
- [Instabug setCrashReportingEnabled: NO ] ;
114
+ IBGCrashReporting. enabled = NO ;
112
115
}
113
116
}
114
117
115
118
RCT_EXPORT_METHOD (setAutoScreenRecordingEnabled:(BOOL )enabled) {
116
- [ Instabug setAutoScreenRecordingEnabled: enabled] ;
119
+ Instabug. autoScreenRecordingEnabled = enabled;
117
120
}
118
121
119
122
RCT_EXPORT_METHOD (setAutoScreenRecordingMaxDuration:(CGFloat)duration) {
120
- [ Instabug setAutoScreenRecordingDuration: duration] ;
123
+ Instabug. autoScreenRecordingDuration = duration;
121
124
}
122
125
123
126
RCT_EXPORT_METHOD (setPreSendingHandler:(RCTResponseSenderBlock)callBack) {
124
127
if (callBack != nil ) {
125
- [Instabug setPreSendingHandler: ^{
128
+ IBGBugReporting. willSendReportHandler = ^{
126
129
[self sendEventWithName: @" IBGpreSendingHandler" body: nil ];
127
- }] ;
130
+ };
128
131
} else {
129
- [Instabug setPreSendingHandler: nil ] ;
132
+ IBGBugReporting. willSendReportHandler = nil ;
130
133
}
131
134
}
132
135
133
136
RCT_EXPORT_METHOD (setPreInvocationHandler:(RCTResponseSenderBlock)callBack) {
134
137
if (callBack != nil ) {
135
- [Instabug setPreInvocationHandler: ^{
138
+ IBGBugReporting. willInvokeHandler = ^{
136
139
[self sendEventWithName: @" IBGpreInvocationHandler" body: nil ];
137
- }] ;
140
+ };
138
141
} else {
139
- [Instabug setPreInvocationHandler: nil ] ;
142
+ IBGBugReporting. willInvokeHandler = nil ;
140
143
}
141
144
}
142
145
143
146
RCT_EXPORT_METHOD (setPostInvocationHandler:(RCTResponseSenderBlock)callBack) {
144
147
if (callBack != nil ) {
145
- [Instabug setPostInvocationHandler: ^(IBGDismissType dismissType, IBGReportType reportType) {
148
+ IBGBugReporting. didDismissHandler = ^(IBGDismissType dismissType, IBGReportType reportType) {
146
149
[self sendEventWithName: @" IBGpostInvocationHandler" body: @{
147
150
@" dismissType" : @(dismissType),
148
151
@" reportType" : @(reportType)
149
152
}];
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
+ };
151
166
} else {
152
- [Instabug setPostInvocationHandler: nil ] ;
167
+ IBGBugReporting. didSelectPromptOptionHandler = nil ;
153
168
}
154
169
}
155
170
@@ -170,13 +185,21 @@ - (dispatch_queue_t)methodQueue {
170
185
}
171
186
172
187
RCT_EXPORT_METHOD (getUnreadMessagesCount:(RCTResponseSenderBlock)callBack) {
173
- callBack (@[@([ Instabug getUnreadMessagesCount ] )]);
188
+ callBack (@[@(Instabug.unreadMessagesCount )]);
174
189
}
175
190
176
191
RCT_EXPORT_METHOD (setInvocationEvent:(IBGInvocationEvent)invocationEvent) {
177
192
[Instabug setInvocationEvent: invocationEvent];
178
193
}
179
194
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
+
180
203
RCT_EXPORT_METHOD (setPushNotificationsEnabled:(BOOL )isPushNotificationEnabled) {
181
204
[Instabug setPushNotificationsEnabled: isPushNotificationEnabled];
182
205
}
@@ -194,28 +217,37 @@ - (dispatch_queue_t)methodQueue {
194
217
foriPad: iPadShakingThreshold];
195
218
}
196
219
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
+
197
228
RCT_EXPORT_METHOD (setFloatingButtonEdge:(CGRectEdge)floatingButtonEdge withTopOffset:(double )floatingButtonOffsetFromTop) {
198
- [Instabug setFloatingButtonEdge: floatingButtonEdge withTopOffset: floatingButtonOffsetFromTop];
229
+ IBGBugReporting.floatingButtonEdge = floatingButtonEdge;
230
+ IBGBugReporting.floatingButtonTopOffset = floatingButtonOffsetFromTop;
199
231
}
200
232
201
233
RCT_EXPORT_METHOD (setLocale:(IBGLocale)locale) {
202
234
[Instabug setLocale: locale];
203
235
}
204
236
205
237
RCT_EXPORT_METHOD (setExtendedBugReportMode:(IBGExtendedBugReportMode)extendedBugReportMode) {
206
- [Instabug setExtendedBugReportMode: extendedBugReportMode] ;
238
+ IBGBugReporting. extendedBugReportMode = extendedBugReportMode;
207
239
}
208
240
209
241
RCT_EXPORT_METHOD (setIntroMessageEnabled:(BOOL )isIntroMessageEnabled) {
210
- [Instabug setIntroMessageEnabled: isIntroMessageEnabled] ;
242
+ IBGBugReporting. introMessageEnabled = isIntroMessageEnabled;
211
243
}
212
244
213
245
RCT_EXPORT_METHOD (setColorTheme:(IBGColorTheme)colorTheme) {
214
246
[Instabug setColorTheme: colorTheme];
215
247
}
216
248
217
249
RCT_EXPORT_METHOD (setPrimaryColor:(UIColor *)color) {
218
- [ Instabug setPrimaryColor: color] ;
250
+ Instabug. tintColor = color;
219
251
}
220
252
221
253
RCT_EXPORT_METHOD (appendTags:(NSArray *)tags) {
@@ -252,20 +284,20 @@ - (dispatch_queue_t)methodQueue {
252
284
attachmentTypes |= IBGAttachmentTypeScreenRecording;
253
285
}
254
286
255
- [Instabug setEnabledAttachmentTypes: attachmentTypes] ;
287
+ IBGBugReporting. enabledAttachmentTypes = attachmentTypes;
256
288
}
257
289
258
290
RCT_EXPORT_METHOD (setChatNotificationEnabled:(BOOL )isChatNotificationEnabled) {
259
- [ Instabug setChatNotificationEnabled: isChatNotificationEnabled] ;
291
+ Instabug. replyNotificationsEnabled = isChatNotificationEnabled;
260
292
}
261
293
262
294
RCT_EXPORT_METHOD (setOnNewMessageHandler:(RCTResponseSenderBlock)callBack) {
263
295
if (callBack != nil ) {
264
- [ Instabug setOnNewMessageHandler: ^{
296
+ Instabug. didRecieveReplyHandler = ^{
265
297
[self sendEventWithName: @" IBGonNewMessageHandler" body: nil ];
266
- }] ;
298
+ };
267
299
} else {
268
- [ Instabug setOnNewMessageHandler: nil ] ;
300
+ Instabug. didRecieveReplyHandler = nil ;
269
301
}
270
302
}
271
303
@@ -332,7 +364,7 @@ - (dispatch_queue_t)methodQueue {
332
364
}
333
365
334
366
RCT_EXPORT_METHOD (setViewHierarchyEnabled:(BOOL )viewHierarchyEnabled) {
335
- [ Instabug setViewHierarchyEnabled: viewHierarchyEnabled] ;
367
+ Instabug. shouldCaptureViewHierarchy = viewHierarchyEnabled;
336
368
}
337
369
338
370
RCT_EXPORT_METHOD (logUserEventWithName:(NSString *)name) {
@@ -343,28 +375,28 @@ - (dispatch_queue_t)methodQueue {
343
375
[Instabug logUserEventWithName: name params: params];
344
376
}
345
377
346
- RCT_EXPORT_METHOD (log:( NSString *)log ) {
347
- [Instabug IBGLog: log] ;
378
+ RCT_EXPORT_METHOD (setIBGLogPrintsToConsole:( BOOL ) printsToConsole ) {
379
+ IBGLog. printsToConsole = printsToConsole ;
348
380
}
349
381
350
382
RCT_EXPORT_METHOD (logVerbose:(NSString *)log) {
351
- [Instabug logVerbose: log];
383
+ [IBGLog logVerbose: log];
352
384
}
353
385
354
386
RCT_EXPORT_METHOD (logDebug:(NSString *)log) {
355
- [Instabug logDebug: log];
387
+ [IBGLog logDebug: log];
356
388
}
357
389
358
390
RCT_EXPORT_METHOD (logInfo:(NSString *)log) {
359
- [Instabug logInfo: log];
391
+ [IBGLog logInfo: log];
360
392
}
361
393
362
394
RCT_EXPORT_METHOD (logWarn:(NSString *)log) {
363
- [Instabug logWarn: log];
395
+ [IBGLog logWarn: log];
364
396
}
365
397
366
398
RCT_EXPORT_METHOD (logError:(NSString *)log) {
367
- [Instabug logError: log];
399
+ [IBGLog logError: log];
368
400
}
369
401
370
402
RCT_EXPORT_METHOD (setSurveysEnabled:(BOOL )surveysEnabled) {
@@ -404,7 +436,7 @@ - (dispatch_queue_t)methodQueue {
404
436
}
405
437
406
438
RCT_EXPORT_METHOD (setVideoRecordingFloatingButtonPosition:(IBGPosition)position) {
407
- [Instabug setVideoRecordingFloatingButtonPosition: position] ;
439
+ IBGBugReporting. videoRecordingFloatingButtonPosition = position;
408
440
}
409
441
410
442
RCT_EXPORT_METHOD (setThresholdForReshowingSurveyAfterDismiss:(NSInteger )sessionCount daysCount:(NSInteger )daysCount) {
@@ -416,7 +448,7 @@ - (dispatch_queue_t)methodQueue {
416
448
}
417
449
418
450
RCT_EXPORT_METHOD (showFeatureRequests) {
419
- [Instabug showFeatureRequests ];
451
+ [IBGFeatureRequests show ];
420
452
}
421
453
422
454
RCT_EXPORT_METHOD (setShouldShowSurveysWelcomeScreen:(BOOL )shouldShowWelcomeScreen) {
@@ -431,7 +463,7 @@ - (dispatch_queue_t)methodQueue {
431
463
actionTypes |= [boxedValue intValue ];
432
464
}
433
465
434
- [Instabug setEmailFieldRequired: isEmailFieldRequired forAction: actionTypes];
466
+ [IBGFeatureRequests setEmailFieldRequired: isEmailFieldRequired forAction: actionTypes];
435
467
}
436
468
437
469
RCT_EXPORT_METHOD (isRunningLive:(RCTResponseSenderBlock)callback) {
0 commit comments