플러터(Flutter)/플러터 패키지(Flutter Package)
Admob test device registration
SuperKid
2020. 5. 11. 01:00
Admob test device registration
1. 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;
}
}
2. wherever you're calling the ad, use:
AdvertisingService advertisingService = AdvertisingService();
NativeAdmob(
adUnitID: advertisingService
.myProjectNativeAdId(),
...
)