Skip to content

Commit a1c845b

Browse files
authored
Perform block fix (#354)
1 parent 9e08371 commit a1c845b

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Master
2+
3+
* Fixes hang/crash issues on iOS 9 devices
4+
15
## v8.5.2 (2019-08-04)
26

37
* Fixes an issue that would cause Android to throw ArrayIndexOutOfBoundsException.

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ - (dispatch_queue_t)methodQueue {
7878
}
7979

8080
RCT_EXPORT_METHOD(invoke) {
81-
[[NSRunLoop mainRunLoop] performBlock:^{
82-
[IBGBugReporting invoke];
83-
}];
81+
[[NSRunLoop mainRunLoop] performSelector:@selector(invoke) target:[IBGBugReporting class] argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
8482
}
8583

84+
8685
RCT_EXPORT_METHOD(invokeWithInvocationModeAndOptions:(IBGInvocationMode)invocationMode options:(NSArray*)options) {
8786
[[NSRunLoop mainRunLoop] performBlock:^{
8887
IBGBugReportingInvocationOption invocationOptions = 0;
@@ -360,15 +359,11 @@ - (dispatch_queue_t)methodQueue {
360359
}
361360

362361
RCT_EXPORT_METHOD(setColorTheme:(IBGColorTheme)colorTheme) {
363-
[[NSRunLoop mainRunLoop] performBlock:^{
364362
[Instabug setColorTheme:colorTheme];
365-
}];
366363
}
367364

368365
RCT_EXPORT_METHOD(setPrimaryColor:(UIColor *)color) {
369-
[[NSRunLoop mainRunLoop] performBlock:^{
370366
Instabug.tintColor = color;
371-
}];
372367
}
373368

374369
RCT_EXPORT_METHOD(appendTags:(NSArray *)tags) {
@@ -571,9 +566,8 @@ - (dispatch_queue_t)methodQueue {
571566
}
572567

573568
RCT_EXPORT_METHOD(showFeatureRequests) {
574-
[[NSRunLoop mainRunLoop] performBlock:^{
575-
[IBGFeatureRequests show];
576-
}];
569+
[[NSRunLoop mainRunLoop] performSelector:@selector(show) target:[IBGFeatureRequests class] argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
570+
577571
}
578572

579573
RCT_EXPORT_METHOD(setShouldShowSurveysWelcomeScreen:(BOOL)shouldShowWelcomeScreen) {
@@ -673,11 +667,11 @@ - (dispatch_queue_t)methodQueue {
673667
}
674668

675669
RCT_EXPORT_METHOD(show) {
676-
[[NSRunLoop mainRunLoop] performBlock:^{
677-
[Instabug show];
678-
}];
670+
671+
[[NSRunLoop mainRunLoop] performSelector:@selector(show) target:[Instabug class] argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
679672
}
680673

674+
681675
RCT_EXPORT_METHOD(setReportTypes:(NSArray*) types ) {
682676
IBGBugReportingReportType reportTypes = 0;
683677
for (NSNumber *boxedValue in types) {
@@ -691,23 +685,26 @@ - (dispatch_queue_t)methodQueue {
691685
}
692686

693687
RCT_EXPORT_METHOD(showBugReportingWithReportTypeAndOptions:(IBGBugReportingReportType)type options:(NSArray*) options) {
694-
[[NSRunLoop mainRunLoop] performBlock:^{
695688
IBGBugReportingOption parsedOptions = 0;
696689
for (NSNumber *boxedValue in options) {
697690
parsedOptions |= [boxedValue intValue];
698691
}
699-
[IBGBugReporting showWithReportType:type options:parsedOptions];
700-
}];
692+
NSArray* args = @[@(type), @(parsedOptions)];
693+
[[NSRunLoop mainRunLoop] performSelector:@selector(showBugReportingWithReportTypeAndOptionsHelper:) target:self argument:args order:0 modes:@[NSDefaultRunLoopMode]];
694+
}
695+
696+
- (void) showBugReportingWithReportTypeAndOptionsHelper:(NSArray*)args {
697+
IBGBugReportingReportType parsedreportType = [args[0] intValue];
698+
IBGBugReportingOption parsedOptions = [args[1] intValue];
699+
[IBGBugReporting showWithReportType:parsedreportType options:parsedOptions];
701700
}
702701

703702
RCT_EXPORT_METHOD(setChatsEnabled:(BOOL)isEnabled) {
704703
IBGChats.enabled = isEnabled;
705704
}
706705

707706
RCT_EXPORT_METHOD(showChats) {
708-
[[NSRunLoop mainRunLoop] performBlock:^{
709-
[IBGChats show];
710-
}];
707+
[[NSRunLoop mainRunLoop] performSelector:@selector(show) target:[IBGChats class] argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
711708
}
712709

713710
RCT_EXPORT_METHOD(setRepliesEnabled:(BOOL) isEnabled) {
@@ -721,9 +718,7 @@ - (dispatch_queue_t)methodQueue {
721718
}
722719

723720
RCT_EXPORT_METHOD(showReplies) {
724-
[[NSRunLoop mainRunLoop] performBlock:^{
725-
[IBGReplies show];
726-
}];
721+
[[NSRunLoop mainRunLoop] performSelector:@selector(show) target:[IBGReplies class] argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
727722
}
728723

729724
RCT_EXPORT_METHOD(setOnNewReplyReceivedCallback:(RCTResponseSenderBlock) callback) {

0 commit comments

Comments
 (0)