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.
Notes
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 idfav info
app.quit('*') -- close all apps
local old_idfavs = clear.idfav()
local f = io.open("/var/mobile/Media/1ferver/res/old_idfavs.txt", "wb")
if f then
f:write(old_idfavs)
f:close()
clear.caches() -- clear system caches
sys.alert("Backup succeeded")
else
clear.idfav(old_idfavs) -- restore immediately if backup failed
clear.caches() -- clear system caches
sys.alert("Backup failed")
end
--
-- Restore idfav info from file
local f = io.open("/var/mobile/Media/1ferver/res/old_idfavs.txt", "rb")
if f then
local old_idfavs = f:read("*a")
f:close()
close_all_app() -- close all apps
local current_idfavs = clear.idfav(old_idfavs)
if current_idfavs then
f = io.open("/var/mobile/Media/1ferver/res/current_idfavs.txt", "wb")
f:write(current_idfavs) -- save current idfav info to another file
f:close()
clear.caches() -- clear system caches
sys.alert("Restore idfav succeeded")
else
sys.alert("Restore idfav failed")
end
else
sys.alert("Open file failed")
end