When users browse the pages of the app, if pop-up advertisements that they do not like often pop up, it will not only damage the user's browsing experience, but also make users feel disgusted with the content of the advertisements. As an app marketer, it is very important to accurately capture the needs of users when placing advertisements online without causing user resistance. When users are unwilling to authorize their personal information, such as age, gender, hobbies and other privacy data to the app, it is a good choice to place advertisements based on the page the user is browsing, which determines whether an advertisement can be efficiently targeted to Target users.
For example, a user is reading an article in a news app about the accelerated development of new energy vehicles at this stage, the mileage has greatly increased, and cities are also accelerating the deployment of charging piles. If the targeted advertising mechanism understands the context of the article, the user continues to browse In the news, you may see native advertisements about the test drive invitations of nearby new energy vehicle 4S stores, or advertisements about the purchase discounts of a certain brand of new energy vehicles, so as to accurately locate the needs of target users.
HMS Core advertising services support personalized ads and non-personalized ads. Non-personalized ads are ads that are not based on users' past behavior and use contextual information for targeting. Contextual information includes rough (e.g. city-level) geolocation of the user's authorized current location, information that comes with the device (e.g. phone model, etc.), and the content of the current app or the content of the current app's search keywords. When a user browses a certain content in the App, or searches for a certain topic or keyword expressing a specific interest in the topic, the contextual advertising system will scan for a specific word or combination of words, based on the content of the page the user is browsing. Push ads.
Today, when data security and personal privacy are facing huge challenges, many users are very resistant to the activities of collecting personal privacy data, which means that the precise advertisements are no longer accurate. HMS Core is now integrated with the ability to request advertisements based on contextual information , which can also achieve precise delivery while protecting user privacy.
Development steps
1. Prerequisites
HUAWEI Ads SDK depends on HMS Core (APK) 4.0.0.300 and above. If HMS Core (APK) 4.0.0.300 and above is not installed on the device, the related interfaces of the HUAWEI Ads SDK cannot be used.
Before developing applications, you need to register as a developer on the Huawei Developer Alliance website and complete real-name authentication. For details, see Account Registration Authentication .
See Creating a Project and Adding an Application under a Project to complete the application creation.
2. Import HUAWEI Ads SDK
Huawei provides the Maven warehouse integration method to import the HUAWEI Ads SDK package. Before starting development, you need to integrate the HUAWEI Ads SDK into your Android Studio development environment.
Configure the Maven warehouse address.
The codebase configuration for Android Studio differs between Gradle plugin versions below 7.0, 7.0 , and 7.1 and above . Please select the corresponding configuration process according to your current Gradle plugin version.
3. Configure network permissions
To allow HTTP(S) network requests on mobile phones with targetSdkVersion 28 and above, do the following configuration in "AndroidManifest.xml".
<application
...
android:usesCleartextTraffic="true"
>
...
</application>
4. Configure the obfuscation script
Before compiling the APK, you need to configure the obfuscation configuration file to avoid obfuscation of the HUAWEI Ads SDK resulting in abnormal functions.
Open the "proguard-rules.pro" obfuscation configuration file in the application-level root directory of the Android project, and add the obfuscation configuration that excludes the HUAWEI Ads SDK.
-keep class com.huawei.openalliance.ad.** { *; }
-keep class com.huawei.hms.ads.** { *; }
5. Initialize SDK
You can call the HwAds.init (Context context) interface in the AdSampleApplication class to initialize the SDK or in the Activity to initialize the SDK.
• It is recommended to call the HwAds.init (Context context) interface to initialize the HUAWEI Ads SDK when the application starts. You need to implement the AdSampleApplication class yourself.
6. Request ads based on contextual information
The HUAWEI Ads SDK provides the setContentBundle method in the AdParam.Builder class for you to set and carry context information when requesting an ad.
The sample code looks like this:
RewardAd rewardAd = new RewardAd(this, rewardId);
AdParam.Builder adParam = new AdParam.Builder();
String mediaContent = "{\"channelCategoryCode\":[\"剧集\"],\"title\":[\"西游记\"],\"tags\":[\"神魔\",\"冒险\"],\"relatedPeople\":[\"张三\"],\"content\":[\"该剧讲述了师徒四人西天取经……\"],\"contentID\":[\"123123\"],\"category\":[\"经典剧场\"],\"subcategory\":[\"古装\"],\"thirdCategory\":[\"悬疑\"]}\n";
adParam.setContentBundle(mediaContent);
rewardAd.loadAd(adParam.build(), new RewardAdLoadListener());
Learn more details>>
Visit the official website of Huawei Developer Alliance
Get development guidance documents
Huawei Mobile Services Open Source Warehouse Address: GitHub , Gitee
Follow us to know the latest technical information of HMS Core for the first time~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。