• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.identifier.oaid (OAID) (System API)
2
3The **OAID** module provides APIs for obtaining and resetting Open Anonymous Device Identifiers (OAIDs).
4
5> **NOTE**
6> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7> To use the APIs for obtaining OAIDs, you must [request the ohos.permission.APP_TRACKING_CONSENT permission](../../security/AccessToken/request-user-authorization.md).
8> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.identifier.oaid (OAID)](js-apis-oaid.md).
9
10## Modules to Import
11
12```ts
13import { identifier } from '@kit.AdsKit';
14```
15
16## identifier.resetOAID
17
18resetOAID(): void
19
20Resets an OAID.
21
22**System API**: This is a system API.
23
24**System capability**: SystemCapability.Advertising.OAID
25
26**Error codes**
27
28For details about the following error codes, see [OAID Error Codes](errorcode-oaid.md).
29
30| ID   | Error Message                                                                        |
31|----------|------------------------------------------------------------------------------|
32| 202      | Permission verification failed. A non-system application calls a system API. |
33| 17300001 | System internal error.                                                       |
34| 17300002 | Not in the trust list.                                                       |
35
36**Example**
37
38```ts
39import { identifier } from '@kit.AdsKit';
40import { hilog } from '@kit.PerformanceAnalysisKit';
41
42try {
43  identifier.resetOAID();
44} catch (err) {
45  hilog.error(0x0000, 'testTag', `Fail to reset OAID. Code is ${err.code}, message is ${err.message}`);
46}
47```
48