Facebook audience network bidding code in android studio
Bidding is necessary for every Audience network user. This is now compulsory to use audience network ads in their apps. If you are interested in the Facebook audience network then you have to bid with other ad networks. In my previous tutorial, I explain fully about AdMob and Facebook audience network bidding. It will be better for you to watch my previous tutorial that help you understand the benefit of bidding. As I explained before that's why I am not explaining it today. I am going to code directly and I also provide audience network bidding code.
In this tutorial, I will use an AdMob account to bidding with the Facebook audience network. I have also used the AdMob account in my previous tutorial. Today I will show, what type of code we need to implement on our app for bidding. This code shared AdMob and Facebook separately. But I will do very easy processes like copying the audience network bidding code and pasting. Many of us get confused about what type of code they implement, which platform will be better to follow. Both platforms share their guide with some of the code. We have to implement this coding to use AdMob bidding. So Today's tutorial I will share the bidding coding full process.
Implement AdMob ads in your android app
At first, we have to implement AdMob SDK in our android apps. So add the following dependency to your android project. Now we have to initialize AdMob SDK. But there are two types of initializing code in the AdMob guideline. We have to implement mediation initializing code in our android project. Here mediation initializing code below just do copy it and paste it in your project.
implementation 'com.google.android.gms:play-services-ads:20.1.0'
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
Map<String, AdapterStatus> statusMap = initializationStatus.getAdapterStatusMap();
for (String adapterClass : statusMap.keySet()) {
AdapterStatus status = statusMap.get(adapterClass);
Log.d("MyApp", String.format(
"Adapter name: %s, Description: %s, Latency: %d",
adapterClass, status.getDescription(), status.getLatency()));
}
}
});
Add the dependency and paste the AdMob initializing code in your java class. Then import the class by clicking the Alt+Enter button on your keyboard. Now implement your banner and interstitial ad on your project.
Add Facebook audience network SDK
After implementing your banner, an interstitial ad on your project then adds facebook audience network SDK and meditation SDK on your project.
implementation 'com.google.ads.mediation:facebook:6.4.0.0'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.facebook.android:audience-network-sdk:6.5.0'
Create a resource directory on your project
Now we have to create a new resource directory in our resource folder. So keep your mouse in the resource folder, then click the Right button of your mouse. Then click new and then click the Android Resource Directory button and name it XML.
In the XML resource directory, click the right button on your mouse and click new. Now click XML Resource file and named it "network_security_config". In the network_security_config.xml file paste the following code.
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
</network-security-config>
Manifest file audience network bidding code
Open your android project manifest file and this code in <Application></Application> code.
android:fullBackupContent="true"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
Now we have to add the meta-data to our manifest file. Meta-data must be placed in the tag. I give the meta-data code below. So just copy it and paste it on your project.

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/admob_app_id"/>
<meta-data
android:name="com.google.android.gms.ads.flag.rtb_enabled"
android:value="true" />
In meta-data code, always use your real AdMob and Facebook app id.
This simple coding will help you to bidding. I will make a separate video about this topic. So please subscribe to my channel and website also. Stay tuned for the next.
Comments
Post a Comment