Skip to content

Commit

Permalink
Deprecate TestAdUnitIds (#500)
Browse files Browse the repository at this point in the history
* Remove AdUnitId declaration from Ad classes

We don't need to use actual test ids for unit tests.

* update dart.io import

* deprecate testAdUnitId and update test ad unit ids in main.dart

* run flutter format

* remove unnecessary testAdUnitId for Rewarded Interstitial

* update dev-sites for admob and admanager for test ad unit ids

* update version and changelog
  • Loading branch information
srichakradhar committed Jan 28, 2022
1 parent 9b2abb5 commit 7fe38f5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 66 deletions.
3 changes: 3 additions & 0 deletions packages/google_mobile_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.2
* Add support for [Rewarded Interstitial](https://support.google.com/admob/answer/9884467) (beta) ad format.

## 1.0.1

* Fix for [Issue 449](https://github.com/googleads/googleads-mobile-flutter/issues/449).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/** Constants used in the plugin. */
public class Constants {
/** Version request agent. Should be bumped alongside plugin versions. */
public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-1.0.1";
public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-1.0.2";

static final String ERROR_CODE_UNEXPECTED_AD_TYPE = "unexpected_ad_type";
}
17 changes: 13 additions & 4 deletions packages/google_mobile_ads/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

// ignore_for_file: public_member_api_docs

import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

import 'anchored_adaptive_example.dart';
import 'inline_adaptive_example.dart';
import 'fluid_example.dart';
import 'inline_adaptive_example.dart';
import 'reusable_inline_example.dart';

void main() {
Expand Down Expand Up @@ -63,7 +66,9 @@ class _MyAppState extends State<MyApp> {

void _createInterstitialAd() {
InterstitialAd.load(
adUnitId: InterstitialAd.testAdUnitId,
adUnitId: Platform.isAndroid
? 'ca-app-pub-3940256099942544/1033173712'
: 'ca-app-pub-3940256099942544/4411468910',
request: request,
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (InterstitialAd ad) {
Expand Down Expand Up @@ -108,7 +113,9 @@ class _MyAppState extends State<MyApp> {

void _createRewardedAd() {
RewardedAd.load(
adUnitId: RewardedAd.testAdUnitId,
adUnitId: Platform.isAndroid
? 'ca-app-pub-3940256099942544/5224354917'
: 'ca-app-pub-3940256099942544/1712485313',
request: request,
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (RewardedAd ad) {
Expand Down Expand Up @@ -157,7 +164,9 @@ class _MyAppState extends State<MyApp> {

void _createRewardedInterstitialAd() {
RewardedInterstitialAd.load(
adUnitId: RewardedInterstitialAd.testAdUnitId,
adUnitId: Platform.isAndroid
? 'ca-app-pub-3940256099942544/5354046379'
: 'ca-app-pub-3940256099942544/6978759866',
request: request,
rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
onAdLoaded: (RewardedInterstitialAd ad) {
Expand Down
2 changes: 1 addition & 1 deletion packages/google_mobile_ads/ios/Classes/FLTConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/** Versioned request agent string. */
#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-1.0.1"
#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-1.0.2"
47 changes: 19 additions & 28 deletions packages/google_mobile_ads/lib/src/ad_containers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -857,13 +857,11 @@ class BannerAd extends AdWithView {
@override
final BannerAdListener listener;

/// {@template google_mobile_ads.testAdUnitId}
/// A platform-specific AdMob test ad unit ID.
///
/// This ad unit has been specially configured to always return test ads, and
/// developers are encouraged to use it while building and testing their apps.
/// {@endtemplate}
/// {@macro google_mobile_ads.testAdUnitId}
/// Check out developer pages for [Admob](https://developers.google.com/admob/flutter/test-ads)
/// and [AdManager](https://developers.google.com/ad-manager/mobile-ads-sdk/flutter/test-ads) for
/// demo ad units that point to specific test creatives for each format.
@Deprecated(
'Use test ad unit ids from the developer page while creating the ad.')
static final String testAdUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716';
Expand Down Expand Up @@ -1036,9 +1034,11 @@ class NativeAd extends AdWithView {
/// Options to configure the native ad request.
final NativeAdOptions? nativeAdOptions;

/// Check [test ads](https://developers.google.com/admob/android/test-ads) for
/// Check out developer pages for [Admob](https://developers.google.com/admob/flutter/test-ads)
/// and [AdManager](https://developers.google.com/ad-manager/mobile-ads-sdk/flutter/test-ads) for
/// demo ad units that point to specific test creatives for each format.
@Deprecated('Use test ads from the developer page while creating the ad.')
@Deprecated(
'Use test ad unit ids from the developer page while creating the ad.')
static final String testAdUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/2247696110'
: 'ca-app-pub-3940256099942544/3986624511';
Expand Down Expand Up @@ -1070,7 +1070,11 @@ class InterstitialAd extends AdWithoutView {
/// Callbacks to be invoked when ads show and dismiss full screen content.
FullScreenContentCallback<InterstitialAd>? fullScreenContentCallback;

/// {@macro google_mobile_ads.testAdUnitId}
/// Check out developer pages for [Admob](https://developers.google.com/admob/flutter/test-ads)
/// and [AdManager](https://developers.google.com/ad-manager/mobile-ads-sdk/flutter/test-ads) for
/// demo ad units that point to specific test creatives for each format.
@Deprecated(
'Use test ad unit ids from the developer page while creating the ad.')
static final String testAdUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/1033173712'
: 'ca-app-pub-3940256099942544/4411468910';
Expand Down Expand Up @@ -1178,13 +1182,11 @@ class RewardedAd extends AdWithoutView {
/// Callbacks for events that occur when attempting to load an ad.
final RewardedAdLoadCallback rewardedAdLoadCallback;

/// {@template google_mobile_ads.testAdUnitId}
/// A platform-specific AdMob test ad unit ID.
///
/// This ad unit has been specially configured to always return test ads, and
/// developers are encouraged to use it while building and testing their apps.
/// {@endtemplate}
/// {@macro google_mobile_ads.testAdUnitId}
/// Check out developer pages for [Admob](https://developers.google.com/admob/flutter/test-ads)
/// and [AdManager](https://developers.google.com/ad-manager/mobile-ads-sdk/flutter/test-ads) for
/// demo ad units that point to specific test creatives for each format.
@Deprecated(
'Use test ad unit ids from the developer page while creating the ad.')
static final String testAdUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/5224354917'
: 'ca-app-pub-3940256099942544/1712485313';
Expand Down Expand Up @@ -1282,17 +1284,6 @@ class RewardedInterstitialAd extends AdWithoutView {
/// Callbacks for events that occur when attempting to load an ad.
final RewardedInterstitialAdLoadCallback rewardedInterstitialAdLoadCallback;

/// {@template google_mobile_ads.testAdUnitId}
/// A platform-specific AdMob test ad unit ID.
///
/// This ad unit has been specially configured to always return test ads, and
/// developers are encouraged to use it while building and testing their apps.
/// {@endtemplate}
/// {@macro google_mobile_ads.testAdUnitId}
static final String testAdUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/5354046379'
: 'ca-app-pub-3940256099942544/6978759866';

/// Optional [ServerSideVerificationOptions].
ServerSideVerificationOptions? serverSideVerificationOptions;

Expand Down
Loading

0 comments on commit 7fe38f5

Please sign in to comment.