1# OAID Service 2 3## When to Use 4 5An Open Anonymous Device Identifier (OAID) is a non-permanent device identifier. The OAID service is useful for media application developers, ad platforms, and tracking platforms alike. Specifically, it provides personalized ads for users while protecting their personal data privacy, and also interact with third-party tracking platforms to provide conversion attribution analysis for advertisers. 6 7 8 9## Available APIs 10 11| API| Description| 12| -------- | -------- | 13| [resetOAID()](../../reference/apis/js-apis-oaid.md#identifierresetoaid): void | Resets an OAID. This is a system API.| 14 15 16## How to Develop 17 181. In the **module.json5** file of the module, configure the [ohos.permission.APP_TRACKING_CONSENT](../../security/permission-list.md#ohospermissionapp_tracking_consent) permission. The sample code is as follows: 19 ``` 20 { 21 "module": { 22 "requestPermissions": [ 23 { 24 "name": "ohos.permission.APP_TRACKING_CONSENT" 25 } 26 ] 27 } 28 } 29 ``` 30 312. 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: 32 ``` 33 import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; 34 import { BusinessError } from '@ohos.base'; 35 import hilog from '@ohos.hilog'; 36 import common from '@ohos.app.ability.common'; 37 38 function requestOAIDTrackingConsentPermissions(context: common.Context): void { 39 // Display a dialog box when the page is displayed to request the user to grant the ad tracking permission. 40 const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); 41 try { 42 atManager.requestPermissionsFromUser(context, ["ohos.permission.APP_TRACKING_CONSENT"]).then((data) => { 43 if (data.authResults[0] == 0) { 44 hilog.info(0x0000, 'testTag', '%{public}s', 'request permission success'); 45 } else { 46 hilog.info(0x0000, 'testTag', '%{public}s', 'user rejected'); 47 } 48 }).catch((err: BusinessError) => { 49 hilog.error(0x0000, 'testTag', '%{public}s', `request permission failed, error: ${err.code} ${err.message}`); 50 }) 51 } catch(err) { 52 hilog.error(0x0000, 'testTag', '%{public}s', `catch err->${err.code}, ${err.message}`); 53 } 54 } 55 ``` 56 573. Call **resetOAID()** (a system API) to reset the OAID. The sample code is as follows: 58 ``` 59 import identifier from '@ohos.identifier.oaid'; 60 import hilog from '@ohos.hilog'; 61 62 // Reset the OAID. 63 try { 64 identifier.resetOAID(); 65 } catch (err) { 66 hilog.error(0x0000, 'testTag', '%{public}s', `reset oaid catch error: ${err.code} ${err.message}`); 67 } 68 ``` 69