0 purchases
admob unit ids
1. Admob Unit IDs #
1.1. What is it? #
Admob Unit IDs is a library that provides a common structure for managing AdMob unit IDs licensed under BSD 3-Clause.
1. Admob Unit IDs
1.1. What is it?
1.2. Motivation
1.3. How To Use
1.3.1. Get library
1.3.2. Import and extend abstract class
1.3.3. Override methods
1.3.4. Call methods to get AdMob Unit IDs
1.3.5. Overview
1.4. More Information
1.2. Motivation #
Provide common functionality regarding unit IDs when implementing AdMob.
Reduce redundant settings when deploying AdMob.
1.3. How To Use #
1.3.1. Get library #
Run this command:
With Flutter:
flutter pub add admob_unit_ids
copied to clipboard
1.3.2. Import and extend abstract class #
import 'package:admob_unit_ids/admob_unit_ids.dart';
class DemoAdmobUnitIDs extends AdmobUnitIDs {
}
copied to clipboard
1.3.3. Override methods #
Method Name
Remarks
releaseAppOpen
Should return unit id of app open for releasing.
releaseBanner
Should return unit id of banner for releasing.
releaseInterstitial
Should return unit id of interstitial for releasing.
releaseInterstitialVideo
Should return unit id of interstitial video for releasing.
releaseNativeAdvanced
Should return unit id of native advanced for releasing.
releaseNativeAdvancedVideo
Should return unit id of native advanced video for releasing.
releaseRewarded
Should return unit id of rewarded for releasing.
releaseRewardedInterstitial
Should return unit id of rewarded interstitial for releasing.
import 'package:universal_io/io.dart';
import 'package:admob_unit_ids/admob_unit_ids.dart';
class DemoAdmobUnitIDs extends AdmobUnitIDs {
@override
String get releaseAppOpen => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseBanner => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseInterstitial => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseInterstitialVideo => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseNativeAdvanced => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseNativeAdvancedVideo => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseRewarded => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseRewardedInterstitial => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
}
copied to clipboard
1.3.4. Call methods to get AdMob Unit IDs #
If you override the above abstract methods in a class that extends from this abstract class, basically no need to use the overridden methods directly. But you can use the methods defined in this abstract class to get the unit ID depends on the application startup status.
The following methods check the application startup status, and returns the unit ID for testing when debugging, and returns the release unit ID implemented in concrete class extended this abstract class when releasing.
Method Name
Remarks
appOpen
Returns the unit id of app open for debugging or releasing.
banner
Returns the unit id of banner for debugging or releasing.
interstitial
Returns the unit id of interstitial for debugging or releasing.
interstitialVideo
Returns the unit id of interstitial video for debugging or releasing.
nativeAdvanced
Returns the unit id of native advanced for debugging or releasing.
nativeAdvancedVideo
Returns the unit id of native advanced video for debugging or releasing.
rewarded
Returns the unit id of rewarded for debugging or releasing.
rewardedInterstitial
Returns the unit id of rewarded interstitial for debugging or releasing.
void main() {
final AdmobUnitIDs admobUnitIDs = DemoAdmobUnitIDs();
// => Unit id for debugging or unit id for releasing.
print(admobUnitIDs.appOpen);
print(admobUnitIDs.banner);
print(admobUnitIDs.interstitial);
print(admobUnitIDs.interstitialVideo);
print(admobUnitIDs.nativeAdvanced);
print(admobUnitIDs.nativeAdvancedVideo);
print(admobUnitIDs.rewarded);
print(admobUnitIDs.rewardedInterstitial);
}
copied to clipboard
1.3.5. Overview #
import 'package:universal_io/io.dart';
import 'package:admob_unit_ids/admob_unit_ids.dart';
class DemoAdmobUnitIDs extends AdmobUnitIDs {
/// The singleton instance of [DemoAdmobUnitIDs].
static final DemoAdmobUnitIDs _singletonInstance = DemoAdmobUnitIDs._internal();
/// The internal default constructor.
DemoAdmobUnitIDs._internal();
/// Returns the singleton instance of [DemoAdmobUnitIDs].
factory DemoAdmobUnitIDs.getInstance() => _singletonInstance;
@override
String get releaseAppOpen => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseBanner => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseInterstitial => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseInterstitialVideo => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseNativeAdvanced => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseNativeAdvancedVideo => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseRewarded => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
@override
String get releaseRewardedInterstitial => Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
: 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
}
void main() {
final AdmobUnitIDs admobUnitIDs = DemoAdmobUnitIDs.getInstance();
// => Unit id for debugging or unit id for releasing.
print(admobUnitIDs.appOpen);
print(admobUnitIDs.banner);
print(admobUnitIDs.interstitial);
print(admobUnitIDs.interstitialVideo);
print(admobUnitIDs.nativeAdvanced);
print(admobUnitIDs.nativeAdvancedVideo);
print(admobUnitIDs.rewarded);
print(admobUnitIDs.rewardedInterstitial);
}
copied to clipboard
1.4. More Information #
AdmobUnitIDs was designed and implemented by Kato Shinya.
Creator Profile
License
Release Note
File a Bug
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.