Use Callbacks in getAllUserAttribute API

This commit is contained in:
DevHossamHassan
2017-06-21 05:42:50 +02:00
parent 4471d3b402
commit 3365be2ef9
2 changed files with 14 additions and 7 deletions
@@ -10,6 +10,8 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.Callback;
import com.instabug.library.Instabug;
@@ -676,8 +678,17 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
* @return all user attributes as HashMap<String, String>
*/
@ReactMethod
public HashMap<String, String> getAllUserAttributes() {
return mInstabug.getAllUserAttributes();
public void getAllUserAttributes(Callback userAttributesCallback) {
WritableMap writableMap = new WritableNativeMap();
try {
HashMap<String, String> map = mInstabug.getAllUserAttributes();
for (HashMap.Entry<String, String> entry : map.entrySet()) {
writableMap.putString(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
e.printStackTrace();
}
userAttributesCallback.invoke(writableMap);
}
/**