flutter_native_admob
flutter_native_admob copied to clipboard
Test device registration function is required.
I know that the emulator always shows test ads. This request is not about that.
If admob support package does not have the function to register real devices for testing, you can be blocked by being considered an abusing action while testing your app on a real device. So this feature is essential.
- example : firebase_admob package const List<String> testDevices = ['xxxxxxx', 'aaaaaaa', ....]; _targetingInfo = MobileAdTargetingInfo( testDevices: testDevices ?? null, keywords: <String>['game', 'money',.....], nonPersonalizedAds: false, childDirected: false, );
Thank you.
Quick work around for you:
Make a service:
class AdvertisingService {
//generic test ID from https://developers.google.com/admob/android/native/start?hl=en-US
String testAdId = 'ca-app-pub-3940256099942544/2247696110';
String myProjectNativeAdId() {
if (isInDebugMode) {
return testAdId;
}
return 'yourAdIdHere';
}
bool get isInDebugMode {
bool inDebugMode = false;
assert(inDebugMode = true);
return inDebugMode;
}
}
and wherever you're calling the ad, use:
AdvertisingService advertisingService = AdvertisingService();
NativeAdmob(
adUnitID: advertisingService
.myProjectNativeAdId(),
...
)
Quick work around for you: Make a service: class AdvertisingService {...
Thank you very much. I will try the code. Apart from this answer, I hope package developers can add this feature as well.