Skip to content

Commit c846613

Browse files
authored
Merge pull request #60 from Instabug/feature/missing_apis
Feature/missing apis
2 parents 655b055 + 5a2ff35 commit c846613

File tree

4 files changed

+115
-2
lines changed

4 files changed

+115
-2
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121

2222
dependencies {
2323
compile 'com.facebook.react:react-native:0.20.+'
24-
compile 'com.instabug.library:instabug:4.2.9'
24+
compile 'com.instabug.library:instabug:4.2.10'
2525

2626
}
2727

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,35 @@ public void run() {
11311131
}
11321132
}
11331133

1134+
/**
1135+
* @param enabled true to show success dialog after submitting a bug report
1136+
*
1137+
*/
1138+
@ReactMethod
1139+
public void setSuccessDialogEnabled(boolean enabled) {
1140+
try {
1141+
mInstabug.setSuccessDialogEnabled(enabled);
1142+
} catch (Exception e) {
1143+
e.printStackTrace();
1144+
}
1145+
}
1146+
1147+
/**
1148+
* Set whether new in app notification received will play a small sound notification
1149+
* or not (Default is {@code false})
1150+
*
1151+
* @param shouldPlaySound desired state of conversation sounds
1152+
* @since 4.1.0
1153+
*/
1154+
@ReactMethod
1155+
public void setEnableInAppNotificationSound(boolean shouldPlaySound) {
1156+
try {
1157+
mInstabug.setEnableInAppNotificationSound(shouldPlaySound);
1158+
} catch (Exception e) {
1159+
e.printStackTrace();
1160+
}
1161+
}
1162+
11341163
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
11351164
switch (key) {
11361165
case SHAKE_HINT:

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,27 @@ module.exports = {
780780
}
781781
},
782782

783+
/**
784+
* @param enabled true to show success dialog after submitting a bug report
785+
*
786+
*/
787+
setSuccessDialogEnabled: function(enabled) {
788+
Instabug.setSuccessDialogEnabled(enabled);
789+
},
790+
791+
/**
792+
* Set whether new in app notification received will play a small sound notification
793+
* or not (Default is {@code false})
794+
*
795+
* @param shouldPlaySound desired state of conversation sounds
796+
* @since 4.1.0
797+
*/
798+
setEnableInAppNotificationSound: function(shouldPlaySound) {
799+
if(Platform.OS === 'android') {
800+
Instabug.setEnableInAppNotificationSound(shouldPlaySound);
801+
}
802+
},
803+
783804
/**
784805
* The event used to invoke the feedback form
785806
* @readonly

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#import "InstabugReactBridge.h"
88
#import <Instabug/Instabug.h>
9+
#import <asl.h>
10+
#import <React/RCTLog.h>
11+
#import <os/log.h>
912

1013
@implementation InstabugReactBridge
1114

@@ -28,6 +31,8 @@ - (dispatch_queue_t)methodQueue {
2831

2932
RCT_EXPORT_METHOD(startWithToken:(NSString *)token invocationEvent:(IBGInvocationEvent)invocationEvent) {
3033
[Instabug startWithToken:token invocationEvent:invocationEvent];
34+
RCTAddLogFunction(InstabugReactLogFunction);
35+
RCTSetLogThreshold(RCTLogLevelInfo);
3136
[Instabug setCrashReportingEnabled:NO];
3237
[Instabug setNetworkLoggingEnabled:NO];
3338
}
@@ -228,7 +233,7 @@ - (dispatch_queue_t)methodQueue {
228233
[Instabug logOut];
229234
}
230235

231-
RCT_EXPORT_METHOD(setPostSendingDialogEnabled:(BOOL)isPostSendingDialogEnabled) {
236+
RCT_EXPORT_METHOD(setSuccessDialogEnabled:(BOOL)isPostSendingDialogEnabled) {
232237
[Instabug setPostSendingDialogEnabled:isPostSendingDialogEnabled];
233238
}
234239

@@ -433,4 +438,62 @@ - (NSDictionary *)constantsToExport
433438
};
434439
};
435440

441+
+ (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion {
442+
return [iOSVersion compare:[UIDevice currentDevice].systemVersion options:NSNumericSearch] == NSOrderedDescending;
443+
};
444+
445+
RCTLogFunction InstabugReactLogFunction = ^(
446+
RCTLogLevel level,
447+
__unused RCTLogSource source,
448+
NSString *fileName,
449+
NSNumber *lineNumber,
450+
NSString *message
451+
)
452+
{
453+
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);
454+
455+
456+
NSLog(@"Instabug - REACT LOG: %s", log.UTF8String);
457+
458+
if([InstabugReactBridge iOSVersionIsLessThan:@"10.0"]) {
459+
int aslLevel;
460+
switch(level) {
461+
case RCTLogLevelTrace:
462+
aslLevel = ASL_LEVEL_DEBUG;
463+
break;
464+
case RCTLogLevelInfo:
465+
aslLevel = ASL_LEVEL_NOTICE;
466+
break;
467+
case RCTLogLevelWarning:
468+
aslLevel = ASL_LEVEL_WARNING;
469+
break;
470+
case RCTLogLevelError:
471+
aslLevel = ASL_LEVEL_ERR;
472+
break;
473+
case RCTLogLevelFatal:
474+
aslLevel = ASL_LEVEL_CRIT;
475+
break;
476+
}
477+
asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String);
478+
} else {
479+
switch(level) {
480+
case RCTLogLevelTrace:
481+
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]);
482+
break;
483+
case RCTLogLevelInfo:
484+
os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "%s", [message UTF8String]);
485+
break;
486+
case RCTLogLevelWarning:
487+
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]);
488+
break;
489+
case RCTLogLevelError:
490+
os_log_error(OS_LOG_DEFAULT, "%s", [message UTF8String]);
491+
break;
492+
case RCTLogLevelFatal:
493+
os_log_fault(OS_LOG_DEFAULT, "%s", [message UTF8String]);
494+
break;
495+
}
496+
}
497+
};
498+
436499
@end

0 commit comments

Comments
 (0)