unityads.setHasUserConsent()

Type Function
Return value none
Revision Release 2024.3703
Keywords ads, advertising, unityads, setHasUserConsent
See also unityads.show()
unityads.*

Overview

UnityAds SDK gives an option to work with GDPR user consent manually. You can set a flag indicating whether the user has provided the publisher opt-in consent for the collection and use of personal data.

Syntax

unityads.setHasUserConsent( hasUserConsent )
hasUserConsent (required)

Boolean. If the user has consented, please set the following flag to true, otherwise set it to false.

Example

local unityads = require( "plugin.unityads.v4" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Set user consention
        unityads.setHasUserConsent( true )
    end
end

-- Initialize the Unity Ads plugin
unityads.init( adListener, { appId="YOUR_UNITYADS_GAME_ID" } )