2

is it possible to get all of my users without adding them to through contacts. My problem is that I store users in Firebase and they can have invisible profile. I need to get only users with visible profiles. How can I achieve this?

Thanks

user3637775
  • 499
  • 4
  • 20

1 Answers1

0

You can use the below method code for getting all the user users .You need to pass the users of set type then you will get the response in 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;
}
Sunil Kumar
  • 468
  • 5
  • 12
  • wont it be possible with this calling ApplozicSetting.getInstance(context).enableRegisteredUsersContactCall() ? – user3637775 Nov 18 '16 at 12:24
  • follow this link and add the josn file in to your app after adding the applozic-settings.json file make registeredUserContactListCall :true , startNewButton:true https://www.applozic.com/docs/android-chat-sdk.html#applozic-settings-json-properites-detail then it will load all the registered users by clicking (+)plus button in tool bar – Sunil Kumar Nov 18 '16 at 12:31