Skip to content

Commit 4471d3b

Browse files
Use Callbacks in getUserAttribute API
1 parent cae5a89 commit 4471d3b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,14 @@ public void setUserAttribute(String key, String value) {
645645
* @return the desired user attribute
646646
*/
647647
@ReactMethod
648-
public String getUserAttribute(String key) {
648+
public void getUserAttribute(String key, Callback userAttributeCallback) {
649+
String userAttribute;
649650
try {
650-
return mInstabug.getUserAttribute(key);
651+
userAttribute = mInstabug.getUserAttribute(key);
651652
} catch (Exception e) {
652653
e.printStackTrace();
653-
return null;
654654
}
655+
userAttributeCallback.invoke(userAttribute);
655656
}
656657

657658
/**

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,7 @@ module.exports = {
610610
* @param {userAttributeCallback} userAttributeCallback callback with argument as the desired user attribute value
611611
*/
612612
getUserAttribute: function (key, userAttributeCallback) {
613-
if (Platform.OS === 'ios') {
614-
return Instabug.getUserAttribute(key, userAttributeCallback);
615-
} else if (Platform.OS === 'android') {
616-
return Instabug.getUserAttribute(key);
617-
}
613+
Instabug.getUserAttribute(key, userAttributeCallback);
618614
},
619615

620616
/**

0 commit comments

Comments
 (0)