Skip to main content

Personalized Ads (sys.personalized_advertising / sys.set_personalized_advertising)

This function is available in versions after 20260529

Declaration

allow_personalized_ads = sys.personalized_advertising()
success = sys.set_personalized_advertising(allow_personalized_ads)

Parameters

  • allow_personalized_ads
    Boolean. Whether personalized ads are allowed. true means allowed, false means not allowed.

Returns

  • allow_personalized_ads
    Boolean or nil. Whether personalized ads are currently allowed. Returns nil when the value cannot be read.
  • success
    Boolean. Whether the setting was applied successfully.

Description

Gets or sets the Settings > Privacy & Security > Apple Advertising > Personalized Ads switch.
The setting name or location may differ slightly across iOS versions.

Example

local allow = sys.personalized_advertising()

if type(allow) == "boolean" then
sys.set_personalized_advertising(false)

-- Restore the previous state when needed
sys.set_personalized_advertising(allow)
else
sys.toast("Cannot read personalized ads setting")
end