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