Reset IDFA/V (clear.idfav)
Declaration
oldInfo = clear.idfav([ newInfo ])
Parameters
- newInfo
String, optional. Provide a specific idfav info string to set as the device's new idfav.
If omitted, the device's current idfav will be cleared and iOS will re-generate it later.
Pass "read" to read the current device idfav without clearing.
Returns
- oldInfo
String or nil. The device's previous idfav info on success; nil on failure.
Description
Reset device identifiers such as IDFA and IDFV.
If an invalid idfav string is provided, the operation fails and returns nil.
Without parameters, the current idfav is cleared and iOS will randomly reassign a new one afterward.
You may save the returned idfav string to a file for later restore by passing it back as the parameter.
Example
-- Backup and clear idfav data
app.quit('*') -- close all apps
local old_idfavs = clear.idfav("read") -- read the current idfav data
local ok, err = file.writes(XXT_SCRIPTS_PATH.."/old_idfavs.txt", old_idfavs) -- save the current idfav data to a file
if ok then
clear.idfav() -- clear idfav data
sys.alert("Backup succeeded")
else
sys.alert("Backup failed\n"..tostring(err))
end
-- Restore idfav data from a file
app.quit('*') -- close all apps
local old_idfavs, err = file.reads(XXT_SCRIPTS_PATH.."/old_idfavs.txt") -- read the saved idfav data
if old_idfavs then
local current_idfavs = clear.idfav(old_idfavs)
if current_idfavs then
local ok, err = file.writes(XXT_SCRIPTS_PATH.."/current_idfavs.txt", current_idfavs) -- save the current idfav data to another file
sys.alert("Successfully restored idfav data")
else
sys.alert("Failed to restore idfav data")
end
else
sys.alert("Failed to open file\n"..tostring(err))
end
Note: Uses sys.alert, file.reads, file.writes, app.quit