Implement a custom age gate in your app. Set user age status to support compliance with child data privacy laws.
Read time 1 minuteLast updated 6 months ago
If a publisher or mediator implements a custom age gate solution, they can use the following API to pass an age gate flag to the Unity Ads SDK. If Unity receives this flag, its built-in age gate will not appear.
// If the user is over the specified age limit:MetaData ageGateMetaData = new MetaData("privacy");ageGateMetaData.Set("useroveragelimit", "true");Advertisement.SetMetaData(ageGateMetaData);// If the user is under the specified age limit:MetaData ageGateMetaData = new MetaData("privacy");gdprMetaData.Set("useroveragelimit", "false");Advertisement.SetMetaData(ageGateMetaData);
Note
You must commit the changes to the
MetaData
object for each value before trying to set another value. The second parameter is an object (a string in this example). Using a boolean value will result in an error.
// If the user is over the specified age limit:UADSMetaData *ageGateMetaData = [[UADSMetaData alloc] init];[ageGateMetaData set:@"privacy.useroveragelimit" value:@YES];[ageGateMetaData commit];// If the user is under the specified age limit:UADSMetaData *ageGateMetaData = [[UADSMetaData alloc] init];[ageGateMetaData set:@"privacy.useroveragelimit" value:@NO];[ageGateMetaData commit];
Note
You must commit the changes to the
MetaData
object for each value before trying to set another value.
// If the user is over the specified age limit:MetaData ageGateMetaData = new MetaData(this);ageGateMetaData.set("privacy.useroveragelimit", true);ageGateMetaData.commit();// If the user is under the specified age limit:MetaData ageGateMetaData = new MetaData(this);ageGateMetaData.set("privacy.useroveragelimit", false);ageGateMetaData.commit();
Note
You must commit the changes to the
MetaData
object for each value before trying to set another value.