Himanshu Chauhan
Himanshu Chauhan

Reputation: 1221

How to get Display Name of Contact by User ID in Applozic?

I am using Digits by Twitter alongside Applozic SDK. I am creating a custom contact list, by using Find Friends provided by Digits, and then using their friends' IDs to get their display name from Applozic.

This my code:

Log.e("Friend ID", user.idStr);
AppContactService appContactService = new AppContactService(context);
Contact contact = appContactService.getContactById(user.idStr);
Log.e("Friend Display Name", contact.getDisplayName());

This is my logcat output:

E/Friend ID: 753958303214870528
E/Friend Display Name: 753958303214870528
E/Friend ID: 751769088456790016
E/Friend Display Name: 751769088456790016

As you can see, even getDisplayName() returns UserID. This is my Applozic Dashboard

enter image description here.

Is there anything I am doing wrong??

Upvotes: 1

Views: 567

Answers (1)

Sunil Kumar
Sunil Kumar

Reputation: 468

For this you need to make server call and get the User details from server. The above method which your are using it will only check from local data base

You can user this method to get the details from server

 Set<String> userIds = new HashSet<>();
             userIds.add("user1");
             userIds.add("user2");
             userIds.add("user3");

   UserService.getInstance(context).processUserDetails(userIds); //server call

   AppContactService appContactService = new AppContactService(context);
   Contact contact = appContactService.getContactById("user1");
            if(contact != null){
               Log.e("Friend Display Name", contact.getDisplayName());
              }

Upvotes: 1

Related Questions