duyduong / flutter_native_admob

Plugin to integrate native firebase admob to Flutter application
MIT License
62 stars 85 forks source link

Test device registration function is required. #39

Open exptk3 opened 4 years ago

exptk3 commented 4 years ago

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.

Thank you.

M1Joe commented 4 years ago

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(),
...
)
exptk3 commented 4 years ago

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.