flutter_native_admob icon indicating copy to clipboard operation
flutter_native_admob copied to clipboard

Test device registration function is required.

Open exptk3 opened this issue 4 years ago • 2 comments

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.

exptk3 avatar May 07 '20 07:05 exptk3

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(),
...
)

M1Joe avatar May 10 '20 14:05 M1Joe

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.

exptk3 avatar May 10 '20 16:05 exptk3