cancel
Showing results for 
Search instead for 
Did you mean: 

Clarity on what I need to do with the User Age Group API

MiddleMan82
Protege

My app is for mixed ages, so I understand I need to use the API to get the age group of the user. But what am I meant to do with that information?
The only platform services I use are the leaderboard and getting the username for the leaderboard. I've seen here (Platform Solutions: Unity | Oculus Developers) that an app which is primarily for children under 13 can't use leaderboards. But what about an app for a mixed age group?

Do I just simply need to check the age?

Do I need to disable the leaderboard if the user under 13?
Do I need to close the app if they are under 10?
None of this is clear in the docs. Please tell me what is required.

24 REPLIES 24

zeshow
Explorer

I have the same question.  Following.

DFM31
Honored Guest

Great questions!  I wish I can help you, but I too am stuck in your same situation.  My app is a mixed age app, but it does not use any type of platform services.  It doesn't have any in-app ads or anything like that.  Meta blindly asks that we implement their user age API but does not show or describe how/where to do it.  It's so infuriating!  I just added UserAgeCategory.Report(AppAgeCategory.Ch); to a scene builder script in a Start() method.  That's all I could think of doing.  However, who knows if that complies with their requirements. 

zeshow
Explorer

Since the documentation said that we must choose one of two methods, and "This API should only be used if you know the date of birth (including the day, month, and year) of the user."  I don't have date of birth info from the players,  then I guess i need to use  UserAgeCategory.Get()

go I call:

UserAgeCategory.Get().OnComplete(GetUserAgeCallBack);

and then for callback:

void GetUserAgeCallBack(Message<UserAccountAgeCategory> msg)

but msg.IsError would always show an error.  So I can't verify whether i have successfully retrived the user age category.  And I also don't know what we are supposed to do with this age cat value after we retrieve it.  Do we simply call the get function, and that's all we need to do?

It looks like you are doing the code right. You need to grant the app access to the user age group on your Meta development page for the app. It's under Requirements/Data Use Checkup. I was getting an error until Meta had approved that.

I still don't know what to do with the info though. I'm sure I read somewhere that they will check if we are calling it, but won't check anything else, so until I get a clear answer from them that's all I can do for now. And since Meta really don't care about small developers anymore, I doubt we will get an answer.

bpears
Explorer

I agree with the  frustrations here. Here is what I am about to implement. Hope this helps. Uses language locale and considers app content rating in that locale which you will have to hard code like I did, and varies depending on your app. Also caches entitlement and if the age was appropriate in player prefs. Then you can reference it offline and throughout your app and only have to run this on the load screen. Useful to check age category later in the game if you have achievements/leaderboards etc so you don't use them if it's a child.

void Awake()
    {
        try
        {
            Core.AsyncInitialize();
            Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
            UserAgeCategory.Get().OnComplete(GetUserAgeCallBack);
        }
        catch (UnityException e)
        {
            Debug.LogError("Platform failed to initialize exception.");
            Debug.LogException(e);
        }
        if (PlayerPrefs.HasKey("ageIsOk"))
        {
            if(PlayerPrefs.GetInt("ageIsOk") == 1)
            {
                ageIsOK = true;
            }
            else
            {
                ageIsOK = false;
                userAgeErrorUI.SetActive(true);
            }
        }
        else
        {
            ageIsOK = false;
        }
        if (PlayerPrefs.HasKey("isEntitled"))
        {
            if (PlayerPrefs.GetInt("isEntitiled") == 1)
            {
                entitled = true;
            }
            else
            {
                entitled = false;
                entitlementErrorUI.SetActive(true);
            }
        }
        else
        {
            entitled = false;
        }
}
void Update(){
if(entitled && ageIsOk)
{
//run app
}
}

 

private void GetUserAgeCallBack(Message<UserAccountAgeCategory> msg)
    {
        var uaac = msg.GetUserAccountAgeCategory();
        if (!msg.IsError)
        {            
            string location = Oculus.Platform.Users.GetLoggedInUserLocale();
            int minAge;
            if (location.ToUpper().Contains("EN-US") || location.ToUpper().Contains("KO") || location.ToUpper().Contains("EN-AU") || location.ToUpper().Contains("PT-BR"))
            {
                minAge = 10;//child
            }
            else if (location.ToUpper().Contains("DE"))
            {
                minAge = 12;//child
            }
            else 
            {
                minAge = 16;//teen
            }
            if (uaac.AgeCategory == AccountAgeCategory.Ch)
            {
                UserAgeCategory.Report(AppAgeCategory.Ch);
                PlayerPrefs.SetString("ageCategory", "Ch");
                if (minAge < 13)
                {
                    ageOK = true;
                    PlayerPrefs.SetInt("ageIsOk", 1);
                }
                else
                {
                    ageOK = false;
                    PlayerPrefs.SetInt("ageIsOk", 0);
                }
            }
            else if (uaac.AgeCategory == AccountAgeCategory.Tn)
            {
                UserAgeCategory.Report(AppAgeCategory.Nch);
                PlayerPrefs.SetString("ageCategory", "Nch");
                ageOK = true;
                PlayerPrefs.SetInt("ageIsOk", 1);
            }
            else if (uaac.AgeCategory == AccountAgeCategory.Ad)
            {
                UserAgeCategory.Report(AppAgeCategory.Nch);
                PlayerPrefs.SetString("ageCategory", "Nch");
                ageOK = true;
                PlayerPrefs.SetInt("ageIsOk", 1);
            }
        }
        else
        {
            Debug.Log(msg.GetError());
        }
    }

    private void EntitlementCallback(Message msg)
    {
        if (!msg.IsError)
        {           
            PlayerPrefs.SetInt("isEntitled", 1);
        }
        else
        {
            PlayerPrefs.SetInt("isEntitled", 0);
        }
    }

 

zeshow
Explorer

I got my issue resolved.  So I just did a simple call of the function UserAgeCategory.Get(); once at the beginning of the app.  and that's all. I submitted the new build, grant the app access to the user age group. I did not do anything else after retrieving the ageCategory data from Meta. 

Meta approved it within 2 days.  Not sure what's the point of all this, but maybe it's for some legal issue, or perhaps they will enforce something more stringent in the future.  But at least it's resolved for now.

javicii_new
Honored Guest

Have you not even needed to call a callback afterwards?
Has just adding that line of code been enough?
thanks for your help

No callback needed. Yeah it's kinda pointless but maybe they have plans on the future for more age specific features, and trying to get all developers to hook up to their API.

Sweetfyre
Protege

Is there a special "is using" that is needed for this to function? 

We are trying to use the UserAgeCatagory.Get but it just says it doestn' exist. We updated to oculus platform SDK version 63 via the meta dev hub.

We currently have this

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

If not that it seems like the SDK did not actually update?