getting friends cus...
 
Notifications
Clear all

getting friends custom data

6 Posts
2 Users
0 Reactions
859 Views
 dr.d
(@drzfinestplaya21hotmail-com)
Posts: 10
Active Member
Topic starter
 

how do I get my friendlist custom data ? I spent the whole day trying to find out

so far this is what I have

            Combu.CombuManager.localUser.LoadFriends(Combu.eContactType.Friend, (bool success) => {
                if (Combu.CombuManager.localUser.friends.Length == 0)
                {
                    
                }
                else
                {
                    
                    for (int i = 0; i < Combu.CombuManager.localUser.friends.Length; ++i)
                    {
 
                            testing = Combu.CombuManager.localUser.friends[i].userName;
                            

                                                    //this is what I want get my friends lvl

                           testing = Combu.CombuManager.localUser.friends[i].customData["currentlvl"];
                        
                    }
                }
            });

 
Posted : 24/06/2017 6:26 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

You need to cast Combu.CombuManager.localUser.friends[i] to User, then you can access its customData:

 Combu.CombuManager.localUser.LoadFriends(Combu.eContactType.Friend, (bool success) => {
     if (Combu.CombuManager.localUser.friends.Length == 0)
     {
         Debug.Log("No friends");
     }
     else
     {
         for (int i = 0; i < Combu.CombuManager.localUser.friends.Length; ++i)
         {
             var user = (User)Combu.CombuManager.localUser.friends[i];
             var testing = user.userName + " level: " + user.customData["currentlvl"];
             Debug.Log(testing);
         }
     }
 });

It's working this way because Unity's ILocalUser interface requires "friends" to be a IUserProfile object, so we worked around it.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 24/06/2017 12:29 pm
 dr.d
(@drzfinestplaya21hotmail-com)
Posts: 10
Active Member
Topic starter
 

thank you also how do you check if image is stored in database 

userdata.image  = combuFaceImage;

I also tried to store in custom data but was unable to and I tried calling it but it showed nothing it looks like I'm storing it correctly but when I try to retrieve it it won't show

Combu.CombuManager.localUser.LoadFriends(Combu.eContactType.Friend, (bool success) => {
     if (Combu.CombuManager.localUser.friends.Length == 0)
     {
         Debug.Log("No friends");
     }
     else
     {
         for (int i = 0; i < Combu.CombuManager.localUser.friends.Length++i)
         {
             var user = (User)Combu.CombuManager.localUser.friends[i];
             var testing = user.userName + " level: " + user.customData["currentlvl"];
           face[i] = user.image
        }
   }
 });
also how do I combine Facebook game request with combu message like give a person a life.
I tried using  https://developers.facebook.com/docs/sharing/opengraph/object-api  but I don't see the option to create new object
 
Posted : 25/06/2017 9:44 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

To store a file (like image or anything else) associated to a user you would use a UserFile and could use the property "name" to define what's the file, here is the documentation.

About your other question I'm not an expert Facebook developer and only used authentication and share posts, so I cannot help you with it (if you need custom messages between friends you could for example give a predefined subject to the message and then assign a JSON string to the content, which you will deserialize later if you need to store more "properties" to a message).

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 26/06/2017 12:59 pm
 dr.d
(@drzfinestplaya21hotmail-com)
Posts: 10
Active Member
Topic starter
 

I was able to successfully upload it to file but how do I retrieve it I tried 

Texture2D obj;

var file = (Combu.UserFile)Combu.CombuManager.localUser.friends[i];
file.Download((obj));

 
Posted : 26/06/2017 8:03 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Check the documentation link I sent above, it contains the section that explains how to load the files of a user (UserFile.Load).

Download method accepts a callback that will have a byte array that is the file content, you can use the byte array to create a Texture2D:

 file.Download ((byte[] content) => {
     if (content != null && content.Length > 0) {
         Texture2D tex = new Texture2D(2, 2);
         tex.LoadImage(content);
     }
 });

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 27/06/2017 5:08 am
Share: