1e41f4b71Sopenharmony_ci# Resetting OAID Information (for System Applications Only) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## When to Use 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciThe OAID changes in the following scenarios: 6e41f4b71Sopenharmony_ci- A user restores the factory settings of the device. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci- A system application configures its bundle name in the **etc/advertising/oaid/oaid_service_config.json** file in the device's system directory and calls the **resetOAID()** API to reset the OAID. Note that the bundle name should be appended to the array in the file and separated with others by commas (,). 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ciThe following describes how to configure a system application to reset the OAID. 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Available APIs 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci| API| Description| 15e41f4b71Sopenharmony_ci| -------- | -------- | 16e41f4b71Sopenharmony_ci| [resetOAID()](../../reference/apis-ads-kit/js-apis-oaid-sys.md#identifierresetoaid): void | Resets an OAID. This is a system API.| 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## How to Develop 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci1. In the **module.json5** file of the module, configure the [ohos.permission.APP_TRACKING_CONSENT](../../security/AccessToken/permissions-for-all.md#ohospermissionapp_tracking_consent) permission. The sample code is as follows: 22e41f4b71Sopenharmony_ci ```ts 23e41f4b71Sopenharmony_ci { 24e41f4b71Sopenharmony_ci "module": { 25e41f4b71Sopenharmony_ci "requestPermissions": [ 26e41f4b71Sopenharmony_ci { 27e41f4b71Sopenharmony_ci "name": "ohos.permission.APP_TRACKING_CONSENT", 28e41f4b71Sopenharmony_ci "reason": "$string:reason", 29e41f4b71Sopenharmony_ci "usedScene": { 30e41f4b71Sopenharmony_ci "abilities": [ 31e41f4b71Sopenharmony_ci "EntryFormAbility" 32e41f4b71Sopenharmony_ci ], 33e41f4b71Sopenharmony_ci "when": "inuse" 34e41f4b71Sopenharmony_ci } 35e41f4b71Sopenharmony_ci } 36e41f4b71Sopenharmony_ci ] 37e41f4b71Sopenharmony_ci } 38e41f4b71Sopenharmony_ci } 39e41f4b71Sopenharmony_ci ``` 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci2. Request authorization from the user in a dialog box when the application is started. For details about how to obtain the context, see [Context](../../application-models/application-context-stage.md). The sample code is as follows: 42e41f4b71Sopenharmony_ci ```ts 43e41f4b71Sopenharmony_ci import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; 44e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 45e41f4b71Sopenharmony_ci import hilog from '@ohos.hilog'; 46e41f4b71Sopenharmony_ci import common from '@ohos.app.ability.common'; 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci function requestOAIDTrackingConsentPermissions(context: common.Context): void { 49e41f4b71Sopenharmony_ci // Display a dialog box when the page is displayed to request the user to grant the ad tracking permission. 50e41f4b71Sopenharmony_ci const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); 51e41f4b71Sopenharmony_ci try { 52e41f4b71Sopenharmony_ci atManager.requestPermissionsFromUser(context, ["ohos.permission.APP_TRACKING_CONSENT"]).then((data) => { 53e41f4b71Sopenharmony_ci if (data.authResults[0] == 0) { 54e41f4b71Sopenharmony_ci hilog.info(0x0000, 'testTag', '%{public}s', 'request permission success'); 55e41f4b71Sopenharmony_ci } else { 56e41f4b71Sopenharmony_ci hilog.error(0x0000, 'testTag', '%{public}s', 'user rejected'); 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 59e41f4b71Sopenharmony_ci hilog.error(0x0000, 'testTag', '%{public}s', `request permission failed, error: ${err.code} ${err.message}`); 60e41f4b71Sopenharmony_ci }) 61e41f4b71Sopenharmony_ci } catch (err) { 62e41f4b71Sopenharmony_ci hilog.error(0x0000, 'testTag', '%{public}s', `catch err->${err.code}, ${err.message}`); 63e41f4b71Sopenharmony_ci } 64e41f4b71Sopenharmony_ci } 65e41f4b71Sopenharmony_ci ``` 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci3. Call **resetOAID()** (a system API) to reset the OAID. The sample code is as follows: 68e41f4b71Sopenharmony_ci ```ts 69e41f4b71Sopenharmony_ci import identifier from '@ohos.identifier.oaid'; 70e41f4b71Sopenharmony_ci import hilog from '@ohos.hilog'; 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci // Reset the OAID. 73e41f4b71Sopenharmony_ci try { 74e41f4b71Sopenharmony_ci identifier.resetOAID(); 75e41f4b71Sopenharmony_ci } catch (err) { 76e41f4b71Sopenharmony_ci hilog.error(0x0000, 'testTag', '%{public}s', `reset oaid catch error: ${err.code} ${err.message}`); 77e41f4b71Sopenharmony_ci } 78e41f4b71Sopenharmony_ci ``` 79