Skip to main content

Clear Module

Clear Module - clear

Deprecated

The function calls in this module may take a long time, block all coroutines, and do not support interruption. It is recommended to use other third-party tools for clearing.

Clear specific or grouped keychain information (clear.keychain)

Declaration

success = clear.keychain(reverse_domain)

Parameters and Return Values

  • reverse_domain
    • string, typically the reverse domain of the app developer (Reverse Domain), e.g., "com.cardify". Do not pass arbitrary parameters.
  • success boolean

Description

Clears the keychain information of a specific app or app group. If unsure, directly use clear.all_keychain.

Example

clear.keychain
clear.keychain("com.cardify")  -- Clears keychain information related to com.cardify

Clear all app keychain information (clear.all_keychain)

Declaration

success = clear.all_keychain()

Parameters and Return Values

  • success boolean
caution

Calling this will clear the keychain information of all third-party apps.

Revoke specific app privacy permissions (clear.privileges)

Declaration

success = clear.privileges(identifier)

Parameters and Return Values

Description

Revokes various privacy permissions of a specific app in SettingsPrivacy & Security. After the app restarts, it will no longer be able to access related data and may prompt the user for access permission.

Revoke all app privacy permissions (clear.all_privileges)

Declaration

success = clear.all_privileges()

Parameters and Return Values

  • success boolean
caution

Calling this will revoke all privacy permissions of all apps (including system apps).

Clear clipboard (clear.pasteboard)

Declaration

clear.pasteboard()

Description

Some tracking information may exist in the clipboard.

Limitation

You may need to restart the app to continue using the clipboard service.

Clear browser cookies (clear.cookies)

Declaration

clear.cookies()

Description

Some tracking information may exist in browser cookies. This only applies to Safari.

Clear system caches (clear.caches)

Declaration

success = clear.caches()

Parameters and Return Values

  • success boolean
note

This function call will forcibly restart the configd and cfprefsd services.

Example

clear.caches
clear.caches()
--
clear.caches { uicache = true } -- Also rebuild icon cache

Clear all local photos in the album (clear.all_photos)

Declaration

clear.all_photos()

Description

Clears all local photos in the album. This will not affect iCloud Photo Stream. All threads are blocked during the clearing process.

Performance

This may take a very long time.

Clear specific app archive data (clear.app_data)

Declaration

success = clear.app_data(identifier)

Parameters and Return Values

Description

Clears the app archive. All threads are blocked during the clearing process.

Performance

This may take a very long time.

Example

clear.app_data
clear.app_data("com.cardify.tinder")

Clear IDFA/V (clear.idfav)

Declaration

success, old_idfav_table = clear.idfav(new_idfa[, new_idfav_table])

Parameters and Return Values

  • new_idfa
  • new_idfav_table
    • table, optional, pass in new IDFA/V information. If not passed, the new_idfa will be used.
  • success boolean
  • old_idfav_table
    • table, returns the original IDFA/V information. Returns nil if the operation fails.

Description

Resets the system IDFA and IDFV identifiers, i.e., the IDFA/V table.

info

When the new_idfa is "READ", it only reads without clearing or modifying.

note

You do not need to worry about the specific format of the IDFA/V table. Simply pass the return value old_idfav_table from the previous call as the parameter new_idfav_table to restore the system IDFA and IDFV identifiers to their original state.
The IDFA/V table can be safely serialized by the plist module.

Example 1

clear.idfav.read
ok, tab = clear.idfav("READ")
--
sys.alert(ok and tab.LSAdvertiserIdentifier or "Read failed")

Example 2

clear.idfav.reset
-- Read the original IDFA/V table and back it up
ok, tab1 = clear.idfav("READ")
if ok then
plist.write("lsd.plist", tab1)
sys.alert(ok and "Backup successful" or "Backup failed")
end
--
-- Clear the IDFA/V table
ok, tab2 = clear.idfav("00000000-0000-0000-0000-000000000000")
assert(tab1.LSAdvertiserIdentifier == tab2.LSAdvertiserIdentifier)
--
-- Read the backed-up IDFA/V table and restore
oldtab = plist.read("lsd.plist")
if oldtab then
ok, tab3 = clear.idfav(oldtab.LSAdvertiserIdentifier, oldtab)
sys.alert(ok and "Restore successful" or "Restore failed")
end

Clear location caches (clear.location_caches)

Declaration

success = clear.location_caches()

Parameters and Return Values

  • success boolean
note

This function call will forcibly restart the locationd service.

Clear push notification caches (clear.push_notifications)

Declaration

success = clear.push_notifications(identifier)

Parameters and Return Values

info

Passing "*" as the identifier will log out all running apps.

note

This function call will forcibly restart the apsd service.

Clear Safari history and website data (clear.safari)

Declaration

success = clear.safari()

Parameters and Return Values

  • success boolean
info
  • This function call will not clear Safari bookmarks.
  • This function call is equivalent to selecting Clear History and Website Data in SettingsSafari.