File tree 3 files changed +20
-3
lines changed
android/src/main/java/com/instabug/reactlibrary
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 59
59
import org .json .JSONObject ;
60
60
import org .json .JSONTokener ;
61
61
62
+ import java .io .File ;
62
63
import java .lang .reflect .InvocationTargetException ;
63
64
import java .lang .reflect .Method ;
64
65
import java .util .ArrayList ;
@@ -457,8 +458,10 @@ public void setVideoRecordingFloatingButtonPosition(String corner) {
457
458
@ ReactMethod
458
459
public void setFileAttachment (String fileUri , String fileNameWithExtension ) {
459
460
try {
460
- Uri uri = Uri .parse (fileUri );
461
- mInstabug .setFileAttachment (uri , fileNameWithExtension );
461
+ File file = new File (fileUri );
462
+ if (file .exists ()) {
463
+ Instabug .addFileAttachment (Uri .fromFile (file ), fileNameWithExtension );
464
+ }
462
465
} catch (Exception e ) {
463
466
e .printStackTrace ();
464
467
}
Original file line number Diff line number Diff line change @@ -1189,6 +1189,19 @@ const InstabugModule = {
1189
1189
Instabug . setWelcomeMessageMode ( welcomeMessageMode ) ;
1190
1190
} ,
1191
1191
1192
+ /**
1193
+ * Add file to be attached to the bug report.
1194
+ * @param {string } filePath
1195
+ * @param {string } fileName
1196
+ */
1197
+ addFileAttachment : function ( filePath , fileName ) {
1198
+ if ( Platform . OS === 'android' ) {
1199
+ Instabug . setFileAttachment ( filePath , fileName ) ;
1200
+ } else {
1201
+ Instabug . setFileAttachment ( filePath ) ;
1202
+ }
1203
+ } ,
1204
+
1192
1205
callPrivateApi : function ( apiName , param ) {
1193
1206
Instabug . callPrivateApi ( apiName , param ) ;
1194
1207
} ,
Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ - (dispatch_queue_t)methodQueue {
88
88
}
89
89
90
90
RCT_EXPORT_METHOD (setFileAttachment:(NSString *)fileLocation) {
91
- [Instabug setFileAttachment: fileLocation];
91
+ NSURL *url = [NSURL URLWithString: fileLocation];
92
+ [Instabug addFileAttachmentWithURL: url];
92
93
}
93
94
94
95
RCT_EXPORT_METHOD (sendJSCrash:(NSDictionary *)stackTrace) {
You can’t perform that action at this time.
0 commit comments