cancel
Showing results for 
Search instead for 
Did you mean: 

How to get FRIENDS names or IDs (Unity, plateform SDK on PC, C#) ? GetLoggedInUserFriends()

Piflyon
Explorer
Hi,
(I'm french, please excuse my english. I Hope I'm in the right place, as google did not help me, and this forum search function does not allow to filter developper's forum only.)

I am already displaying highscores in a custom online leaderboard (name, score, level reached, etc...). in which I highlight the current player score.

I would like to also highlight user's friends scores. How to get these informations ?

What would be perfect is an either a string Array of friends' names (OculusID I think).

The documentation is totally useless about GetLoggedInUserFriends():
https://developer3.oculus.com/documentation/platform/latest/concepts/dg-presence/

So far, here is how I get user's name  (took me hours to make it work, as there is no working example anywhere)(anywhere else but here now  😉 ) :
===== code ====
void OculusAppelStore() {
Oculus.Platform.Core.Initialize ();
Oculus.Platform.Entitlements.IsUserEntitledToApplication ().OnComplete (OculusVerifDroits);
}
void OculusVerifDroits(Message _msg){
if (!_msg.IsError) {
Debug.Log ("Ok ");
Users.GetLoggedInUser ().OnComplete (OculusLoggedInUser);
} else {
Debug.Log ("Nope " + _msg);
}
}
void OculusLoggedInUser(Message _msg) {
if (!_msg.IsError) {
User u = _msg.GetUser ();
playerName = u.OculusID;
} else {
Debug.Log ("erreur loggedIn");
}
}
===== /code=====
I say it again : it's a custom online leaderboard, I don't use the Oculus'one (too complicated for my developper skills).

Thank you for your help.
Cédric.

5 REPLIES 5

Piflyon
Explorer
Still no answer ? 

juanoldinho
Heroic Explorer
Hi,

Using PlatformManager.cs there are static variables for a user id and username.
PlatformManager.MyID  //returns the Oculus ID of the logged in user
PlatformManager.MyOculusID //returns the Oculus username of the logged in user

You can also perform your own API call

Users.GetLoggedInUser ().OnComplete ((Message<User> msg) => {
Debug.Log("User ID: " + msg.Data.ID);
Debug.Log("Oculus ID: " + msg.Data.OculusID);
});

You should be able to do a similar call for the Logged in Users Friends

Users.GetLoggedInUserFriends ().OnComplete ((Message<UserList> msg) => {
foreach (var friend in msg.Data){
Debug.Log("friend: " + friend);
}
});


Please tag me, @juanoldinho, in your forum post/response if you need immediate assistance or want additional support or context on an issue you are having with our software or integrations.

Having an issue with our platform, services, or integrations?

Try using our new bug tool to report this and receive emailed updates as we proceed to address it internally.

Piflyon
Explorer
Hi Juanoldinho,

Sorry, but nothing works. I'm using Unity and C#. I also use :

using Oculus.Platform;
using Oculus.Platform.Models;

The problems in your answer :

PlatformManager does not exist,
msg.Data does not exist. (no definition for "Data").

Can you complete your help ?
Thank you.

Cédric.

juanoldinho
Heroic Explorer
Hi

Apologies, PlatformManager was my own implementation, so you can disregard the first two lines above. 

The other API calls should function as expected. 
Please tag me, @juanoldinho, in your forum post/response if you need immediate assistance or want additional support or context on an issue you are having with our software or integrations.

Having an issue with our platform, services, or integrations?

Try using our new bug tool to report this and receive emailed updates as we proceed to address it internally.

Piflyon
Explorer
Hi, 

(in the last part of your code, the last foreach).

Finally I got it work with :
Debug.Log (friend.OculusID)
and not "friend" only.
Thank You Juanoldinho.

Cédric.