Open distante opened 3 years ago
I'm interesting this (I'm AdMob user too, and interested at increment income). But this looks not realistic as OSS because it depends on a particular library. If the user needs it, I think it must be forked.
Not really, is up to the user to install the sdk libraries, the plugin just need to check the initialized object.
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.AdapterStatus;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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()));
}
// Start loading ads here...
}
});
}
}
I am not using mediation networks at the moment so I can not really test it now.
Hello! Mediation is implemented for release 3.2.0? I really need this working
does this mean that if you setup admob correctly and within google admob itself you'll define like for instance Meta Audience Network that it doesn't show their advertisements?
In Admob.java
// Initialize AdMob with appId
@PluginMethod
public void initialize(final PluginCall call) {
this.setRequestConfiguration(call);
try {
MobileAds.initialize(
getContext(),
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()));
}
}
}
);
bannerExecutor.initialize();
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
}
Then include the adapter class in build.gradle under dependencies.
implementation 'com.google.ads.mediation:facebook:6.15.0.0'
This worked and I was able to use both admob and meta after configuring mediation on admob.
So if we could mention the SDKs needed somewhere, we should be able to conditionally add them to the build to make this work.
I would love to see this feature implemented, instead of forking the plugin. @rdlabo @distante let me know how I can assist.
@denesh-r this got buried on my notifications till now... Would you be able to create a PR for this?
See:
Context: