Skip to content

Commit 94a17f3

Browse files
committed
📝 New Public APIs for iOS
1 parent 76cdb2c commit 94a17f3

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ module.exports = {
9595
Instabug.setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration)
9696
},
9797

98+
/**
99+
* Returns an array containing the available surveys.
100+
* @param {availableSurveysCallback} availableSurveysCallback callback with
101+
* argument available surveys
102+
*
103+
*/
104+
getAvailableSurveys: function(availableSurveysCallback) {
105+
Instabug.getAvailableSurveys(availableSurveysCallback)
106+
},
107+
98108
/**
99109
* Adds custom logs that will be sent with each report.
100110
* @param {string} log Message to be logged.

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import <Instabug/Instabug.h>
99
#import <Instabug/IBGBugReporting.h>
1010
#import <Instabug/IBGCrashReporting.h>
11+
#import <Instabug/IBGSurveys.h>
1112
#import <Instabug/IBGLog.h>
1213
#import <asl.h>
1314
#import <React/RCTLog.h>
@@ -96,11 +97,11 @@ - (dispatch_queue_t)methodQueue {
9697
}
9798

9899
RCT_EXPORT_METHOD(showSurveyWithToken:(NSString *)surveyToken) {
99-
[Instabug showSurveyWithToken:surveyToken];
100+
[IBGSurveys showSurveyWithToken:surveyToken];
100101
}
101102

102103
RCT_EXPORT_METHOD(hasRespondedToSurveyWithToken:(NSString *)surveyToken callback:(RCTResponseSenderBlock)callback) {
103-
callback(@[@([Instabug hasRespondedToSurveyWithToken:surveyToken])]);
104+
callback(@[@([IBGSurveys hasRespondedToSurveyWithToken:surveyToken])]);
104105
}
105106

106107
RCT_EXPORT_METHOD(setUserStepsEnabled:(BOOL)isUserStepsEnabled) {
@@ -367,6 +368,10 @@ - (dispatch_queue_t)methodQueue {
367368
Instabug.shouldCaptureViewHierarchy = viewHierarchyEnabled;
368369
}
369370

371+
RCT_EXPORT_METHOD(getAvailableSurveys:(RCTResponseSenderBlock)callback) {
372+
callback(@[[IBGSurveys availableSurveys]]);
373+
}
374+
370375
RCT_EXPORT_METHOD(logUserEventWithName:(NSString *)name) {
371376
[Instabug logUserEventWithName:name];
372377
}
@@ -400,30 +405,30 @@ - (dispatch_queue_t)methodQueue {
400405
}
401406

402407
RCT_EXPORT_METHOD(setSurveysEnabled:(BOOL)surveysEnabled) {
403-
[Instabug setSurveysEnabled:surveysEnabled];
408+
IBGSurveys.enabled = surveysEnabled;
404409
}
405410

406411
RCT_EXPORT_METHOD(showSurveysIfAvailable) {
407-
[Instabug showSurveyIfAvailable];
412+
[IBGSurveys showSurveyIfAvailable];
408413
}
409414

410415
RCT_EXPORT_METHOD(setWillShowSurveyHandler:(RCTResponseSenderBlock)callBack) {
411416
if (callBack != nil) {
412-
[Instabug setWillShowSurveyHandler:^{
417+
IBGSurveys.willShowSurveyHandler = ^{
413418
[self sendEventWithName:@"IBGWillShowSurvey" body:nil];
414-
}];
419+
};
415420
} else {
416-
[Instabug setWillShowSurveyHandler:nil];
421+
IBGSurveys.willShowSurveyHandler = nil;
417422
}
418423
}
419424

420425
RCT_EXPORT_METHOD(setDidDismissSurveyHandler:(RCTResponseSenderBlock)callBack) {
421426
if (callBack != nil) {
422-
[Instabug setDidDismissSurveyHandler:^{
427+
IBGSurveys.didDismissSurveyHandler = ^{
423428
[self sendEventWithName:@"IBGDidDismissSurvey" body:nil];
424-
}];
429+
};
425430
} else {
426-
[Instabug setDidDismissSurveyHandler:nil];
431+
IBGSurveys.didDismissSurveyHandler = nil;
427432
}
428433
}
429434

@@ -432,15 +437,15 @@ - (dispatch_queue_t)methodQueue {
432437
}
433438

434439
RCT_EXPORT_METHOD(setAutoShowingSurveysEnabled:(BOOL)autoShowingSurveysEnabled) {
435-
[Instabug setAutoShowingSurveysEnabled:autoShowingSurveysEnabled];
440+
IBGSurveys.autoShowingEnabled = autoShowingSurveysEnabled;
436441
}
437442

438443
RCT_EXPORT_METHOD(setVideoRecordingFloatingButtonPosition:(IBGPosition)position) {
439444
IBGBugReporting.videoRecordingFloatingButtonPosition = position;
440445
}
441446

442447
RCT_EXPORT_METHOD(setThresholdForReshowingSurveyAfterDismiss:(NSInteger)sessionCount daysCount:(NSInteger)daysCount) {
443-
[Instabug setThresholdForReshowingSurveyAfterDismiss:sessionCount daysCount:daysCount];
448+
[IBGSurveys setThresholdForReshowingSurveyAfterDismiss:sessionCount daysCount:daysCount];
444449
}
445450

446451
RCT_EXPORT_METHOD(setSessionProfilerEnabled:(BOOL)sessionProfilerEnabled) {
@@ -452,7 +457,7 @@ - (dispatch_queue_t)methodQueue {
452457
}
453458

454459
RCT_EXPORT_METHOD(setShouldShowSurveysWelcomeScreen:(BOOL)shouldShowWelcomeScreen) {
455-
[Instabug setShouldShowSurveysWelcomeScreen:shouldShowWelcomeScreen];
460+
IBGSurveys.shouldShowWelcomeScreen = shouldShowWelcomeScreen;
456461
}
457462

458463
RCT_EXPORT_METHOD(setEmailFieldRequiredForActions:(BOOL)isEmailFieldRequired

0 commit comments

Comments
 (0)