Before using capabilities of Ads Kit, check whether your app has obtained corresponding permissions. If not, you need to declare these permissions.
Specifically, Ads Kit requires the following permissions:
ohos.permission.INTERNET: used to request and display ads, and report bidding results.
ohos.permission.APP_TRACKING_CONSENT: used to obtain the OAID.
Configure the required permissions in the module.json5 file of the module. The activity tracking permission ohos.permission.APP_TRACKING_CONSENT is a user_grant permission, and reason and abilities are mandatory. For details about the configuration method, please refer to the requestPermissions description.
The sample code is as follows:
{
"module": {
"requestPermissions": [
{
"name": "ohos.permission.APP_TRACKING_CONSENT",
"reason": "$string:reason",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.INTERNET"
}
]
}
}