Silly question I'm sure, but when you make an AdMob app in the admob console, you have a choice of Android or iOS apps. That means 2 different IDs.
Which one should we use in Flutter admob plugin?
FirebaseAdMob.instance.initialize(appId: appId);
How about setting as follows?
import 'dart:io';
FirebaseAdMob.instance.initialize(
appId: Platform.isAndroid
? 'ca-app-pub-NNNNNNNNNNNNNNNN~NNNNNNNNNN'
: 'ca-app-pub-MMMMMMMMMMMMMMMM~MMMMMMMMMM',
);
If you dislike conditional operators you can set as follows.
import 'dart:io';
var appId;
if (Platform.isAndroid) {
appId = 'ca-app-pub-NNNNNNNNNNNNNNNN~NNNNNNNNNN';
} else {
appId = 'ca-app-pub-MMMMMMMMMMMMMMMM~MMMMMMMMMM';
}
FirebaseAdMob.instance.initialize(appId: appId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With