是否可以在不通过联系人添加他们的情况下获得我所有的用户。我的问题是我将用户存储在 Firebase 中,他们可以拥有不可见的个人资料。我只需要获取具有可见配置文件的用户。我怎样才能做到这一点?
谢谢
您可以使用以下方法代码获取所有用户用户。您需要传递设置类型的用户,然后您将在 if(!TextUtils.isEmpty(response)){
public String postUserDetailsByUserIds(Set<String> userIds) {
try {
HttpRequestUtils httpRequestUtils = new HttpRequestUtils(this);
final String userDetailsUrl = "https://apps.applozic.com/rest/ws/user/detail";
if (userIds !=null && userIds.size()>0 ) {
List<String> userDetailsList = new ArrayList<>();
String response = "";
int count = 0;
for (String userId : userIds) {
count++;
userDetailsList.add(userId);
if( count% 60==0){
UserDetailListFeed userDetailListFeed = new UserDetailListFeed();
userDetailListFeed.setContactSync(true);
userDetailListFeed.setUserIdList(userDetailsList);
String jsonFromObject = GsonUtils.getJsonFromObject(userDetailListFeed, userDetailListFeed.getClass());
Log.i(TAG,"Sending json:" + jsonFromObject);
response = httpRequestUtils.postData(userDetailsUrl + "?contactSync=true", "application/json", "application/json", jsonFromObject);
userDetailsList = new ArrayList<String>();
if(!TextUtils.isEmpty(response)){
List<UserDetail> userDetails = (List<UserDetail>) GsonUtils.getObjectFromJson(response, new TypeToken<List<UserDetail>>() {}.getType());
for (UserDetail userDetail : userDetails) {
//Here you will get the user details
Log.i("UserDeatil","userId:"+userDetail.getUserId()) ;
Log.i("UserDeatil","display name:"+userDetail.getDisplayName()) ;
Log.i("UserDeatil","image link:"+userDetail.getImageLink()) ;
Log.i("UserDeatil","phone number:"+userDetail.getPhoneNumber()) ;
}
}
}
}
if(!userDetailsList.isEmpty()&& userDetailsList.size()>0) {
UserDetailListFeed userDetailListFeed = new UserDetailListFeed();
userDetailListFeed.setContactSync(true);
userDetailListFeed.setUserIdList(userDetailsList);
String jsonFromObject = GsonUtils.getJsonFromObject(userDetailListFeed, userDetailListFeed.getClass());
response = httpRequestUtils.postData(userDetailsUrl + "?contactSync=true", "application/json", "application/json", jsonFromObject);
Log.i(TAG, "User details response is :" + response);
if (TextUtils.isEmpty(response) || response.contains("<html>")) {
return null;
}
if (!TextUtils.isEmpty(response)) {
List<UserDetail> userDetails = (List<UserDetail>) GsonUtils.getObjectFromJson(response, new TypeToken<List<UserDetail>>() {}.getType());
for (UserDetail userDetail : userDetails) {
//Here you will get the user details
Log.i("UserDeatil","userId:"+userDetail.getUserId()) ;
Log.i("UserDeatil","display name:"+userDetail.getDisplayName()) ;
Log.i("UserDeatil","image link:"+userDetail.getImageLink()) ;
Log.i("UserDeatil","phone number:"+userDetail.getPhoneNumber()) ;
} }
}
return response;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}