1. AdMob content mapping
Content mapping for apps helps you deliver contextually relevant ads to your users and helps ensure ads are placed near content that’s suitable for your advertisers. This enables more advertisers to bid safely on your inventory, which may help to maximize your revenue. For more details, please refer to here.
⚠️Note: By default, only one URL is allowed. Multi-content URL support allows for up to 4 URLs, and you need to apply to AdMob for this feature.
2. Sample code
● Add content mapping URL
// Supports inputting 1 to 4 URLs
Map<String, Object> localExtra = new HashMap<>();
ArrayList<String> urls = new ArrayList<String>();
urls.add("https://www.example1.com");
urls.add("https://www.example2.com");
urls.add("https://www.example3.com");
urls.add("https://www.example4.com");
localExtra.put(AdmobATConst.CONTENT_URLS,urls);
// Taking ATNative native ads as an example, call setLocalExtra() to pass in content mapping URLs before loading ads
mATNative.setLocalExtra(localExtra);
// Loading ad
mATNative.makeAdRequest();
⚠️Note: The content mapping URLs you enter will remain effective continuously; you do not need to pass the same URL with every request. If a change is necessary, simply pass in the new content.
● Unmap content URL
// Inputs an empty urls
Map<String, Object> localExtra = new HashMap<>();
ArrayList<String> urls = new ArrayList<String>();
localExtra.put(AdmobATConst.CONTENT_URLS,urls);
// Taking ATNative native ads as an example, call setLocalExtra() to pass in content mapping URLs before loading ads
mATNative.setLocalExtra(localExtra);
// Loading ad
mATNative.makeAdRequest();