Skip to content

Commit 872f545

Browse files
SalmaAliSalmaAli
authored andcommitted
📝 change callbacks params in ios to return strings rather than ints
1 parent d41645d commit 872f545

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,31 @@ - (dispatch_queue_t)methodQueue {
145145
RCT_EXPORT_METHOD(setPostInvocationHandler:(RCTResponseSenderBlock)callBack) {
146146
if (callBack != nil) {
147147
IBGBugReporting.didDismissHandler = ^(IBGDismissType dismissType, IBGReportType reportType) {
148-
[self sendEventWithName:@"IBGpostInvocationHandler" body:@{
149-
@"dismissType": @(dismissType),
150-
@"reportType": @(reportType)
151-
}];
148+
NSLog(@"Dismiss Type: %ld",(long)dismissType);
149+
NSLog(@"Report Type: %ld",(long)reportType);
150+
151+
//parse dismiss type enum
152+
NSString* dismissTypeString;
153+
if (dismissType == IBGDismissTypeCancel) {
154+
dismissTypeString = @"CANCEL";
155+
} else if (dismissType == IBGDismissTypeSubmit) {
156+
dismissTypeString = @"SUBMIT";
157+
} else if (dismissType == IBGDismissTypeAddAttachment) {
158+
dismissTypeString = @"ADD_ATTACHMENT";
159+
}
160+
161+
//parse report type enum
162+
NSString* reportTypeString;
163+
if (reportType == IBGReportTypeBug) {
164+
reportTypeString = @"bug";
165+
} else if (reportType == IBGReportTypeFeedback) {
166+
reportTypeString = @"feedback";
167+
} else {
168+
reportTypeString = @"other";
169+
}
170+
NSDictionary *result = @{ @"dismissType": dismissTypeString,
171+
@"reportType": reportTypeString};
172+
[self sendEventWithName:@"IBGpostInvocationHandler" body: result];
152173
};
153174
} else {
154175
IBGBugReporting.didDismissHandler = nil;
@@ -157,9 +178,22 @@ - (dispatch_queue_t)methodQueue {
157178

158179
RCT_EXPORT_METHOD(didSelectPromptOptionHandler:(RCTResponseSenderBlock)callBack) {
159180
if (callBack != nil) {
181+
160182
IBGBugReporting.didSelectPromptOptionHandler = ^(IBGPromptOption promptOption) {
183+
184+
NSString *promptOptionString;
185+
if (promptOption == IBGPromptOptionBug) {
186+
promptOptionString = @"bug";
187+
} else if (promptOption == IBGReportTypeFeedback) {
188+
promptOptionString = @"feedback";
189+
} else if (promptOption == IBGPromptOptionChat) {
190+
promptOptionString = @"chat";
191+
} else {
192+
promptOptionString = @"none";
193+
}
194+
161195
[self sendEventWithName:@"IBGDidSelectPromptOptionHandler" body:@{
162-
@"promptOption": @(promptOption)
196+
@"promptOption": promptOptionString
163197
}];
164198
};
165199
} else {

0 commit comments

Comments
 (0)