Skip to content

Commit cae5a89

Browse files
Use Callbacks in getTags API
1 parent 1365d04 commit cae5a89

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.facebook.react.bridge.ReactMethod;
99
import com.facebook.react.bridge.ReadableArray;
1010
import com.facebook.react.bridge.ReadableMap;
11+
import com.facebook.react.bridge.WritableArray;
12+
import com.facebook.react.bridge.WritableNativeArray;
1113
import com.facebook.react.bridge.Callback;
1214

1315
import com.instabug.library.Instabug;
@@ -348,14 +350,18 @@ public void IBGLog(String message) {
348350
* @see #resetTags()
349351
*/
350352
@ReactMethod
351-
public ArrayList<String> getTags() {
352-
ArrayList<String> tags = new ArrayList<String>();
353+
public void getTags(Callback tagsCallback) {
354+
private WritableArray tagsArray;
353355
try {
354-
tags = mInstabug.getTags();
356+
ArrayList<String> tags = mInstabug.getTags();
357+
tagsArray = new WritableNativeArray();
358+
for (int i = 0; i < tags.size(); i++) {
359+
tagsArray.pushString(tags.get(i));
360+
}
355361
} catch (Exception e) {
356362
e.printStackTrace();
357363
}
358-
return tags;
364+
tagsCallback.invoke(tagsArray);
359365
}
360366

361367
/**

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,7 @@ module.exports = {
346346
* @param {tagsCallback} tagsCallback callback with argument tags of reported feedback, bug or crash.
347347
*/
348348
getTags: function (tagsCallback) {
349-
if (Platform.OS === 'ios') {
350-
Instabug.getTags(tagsCallback);
351-
} else if (Platform.OS === 'android') {
352-
Instabug.getTags();
353-
}
349+
Instabug.getTags(tagsCallback);
354350
},
355351

356352
/**

0 commit comments

Comments
 (0)