Skip to content

Commit e6715e9

Browse files
committed
chore(google-mobile-ads): rename AdMob to GoogleMobileAds
1 parent a969913 commit e6715e9

File tree

12 files changed

+247
-294
lines changed

12 files changed

+247
-294
lines changed

packages/google-mobile-ads/adsconsent/index.android.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export class AdsConsent extends AdsConsentBase {
1111
static _consentForm: com.google.android.ump.ConsentForm;
1212
static _consentInfo: com.google.android.ump.ConsentInformation;
1313
static reset() {
14-
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.reset(Utils.android.getApplicationContext());
14+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdConsent.reset(Utils.android.getApplicationContext());
1515
}
1616
static addTestDevices(deviceIds: string[]) {
1717
this._deviceIds = deviceIds;
1818
}
1919
static getStatus(): AdsConsentStatus {
20-
return org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.getStatus(Utils.android.getApplicationContext()) as any;
20+
return org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdConsent.getStatus(Utils.android.getApplicationContext()) as any;
2121
}
2222
static requestInfoUpdate(): Promise<void> {
2323
return new Promise((resolve, reject) => {
@@ -34,10 +34,10 @@ export class AdsConsent extends AdsConsentBase {
3434
info['tagForUnderAgeOfConsent'] = this._tagForUnderAgeOfConsent;
3535
}
3636

37-
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.requestInfoUpdate(
37+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdConsent.requestInfoUpdate(
3838
Application.android.foregroundActivity || Application.android.startActivity,
3939
JSON.stringify(info),
40-
new org.nativescript.firebase.admob.FirebaseAdmob.Callback<java.lang.Void>({
40+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.Callback<java.lang.Void>({
4141
onSuccess(value) {
4242
resolve();
4343
},
@@ -64,10 +64,10 @@ export class AdsConsent extends AdsConsentBase {
6464

6565
static showForm(): Promise<void> {
6666
return new Promise((resolve, reject) => {
67-
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.show(
67+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdConsent.show(
6868
Application.android.foregroundActivity || Application.android.startActivity,
6969
this._consentForm,
70-
new org.nativescript.firebase.admob.FirebaseAdmob.Callback<java.lang.Void>({
70+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.Callback<java.lang.Void>({
7171
onSuccess(val) {
7272
resolve();
7373
},
@@ -81,9 +81,9 @@ export class AdsConsent extends AdsConsentBase {
8181

8282
static loadForm() {
8383
return new Promise<void>((resolve, reject) => {
84-
org.nativescript.firebase.admob.FirebaseAdmob.AdConsent.load(
84+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdConsent.load(
8585
Utils.android.getApplicationContext(),
86-
new org.nativescript.firebase.admob.FirebaseAdmob.Callback<com.google.android.ump.ConsentForm>({
86+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.Callback<com.google.android.ump.ConsentForm>({
8787
onSuccess(form) {
8888
AdsConsent._consentForm = form;
8989
resolve();

packages/google-mobile-ads/index.android.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ export class InterstitialAd implements IInterstitialAd {
175175

176176
load(): void {
177177
const ref = new WeakRef(this);
178-
this._nativeRequest = org.nativescript.firebase.admob.FirebaseAdmob.InterstitialAd.load(
178+
this._nativeRequest = org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.InterstitialAd.load(
179179
Application.android.foregroundActivity || Application.android.startActivity,
180180
this._adUnitId,
181181
JSON.stringify(this._requestOptions || {}),
182-
new org.nativescript.firebase.admob.FirebaseAdmob.AdCallback({
182+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdCallback({
183183
onEvent(event: string, dataOrError: any) {
184184
const owner = ref.get?.();
185185
switch (event) {
@@ -270,11 +270,11 @@ export class RewardedInterstitialAd implements IRewardedInterstitialAd {
270270

271271
load(): void {
272272
const ref = new WeakRef(this);
273-
this._nativeRequest = org.nativescript.firebase.admob.FirebaseAdmob.RewardedInterstitialAd.load(
273+
this._nativeRequest = org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.RewardedInterstitialAd.load(
274274
Application.android.foregroundActivity || Application.android.startActivity,
275275
this._adUnitId,
276276
JSON.stringify(this._requestOptions || {}),
277-
new org.nativescript.firebase.admob.FirebaseAdmob.AdCallback({
277+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdCallback({
278278
onEvent(event: string, dataOrError: any) {
279279
const owner = ref.get?.();
280280
switch (event) {
@@ -320,10 +320,10 @@ export class RewardedInterstitialAd implements IRewardedInterstitialAd {
320320
this.native.setImmersiveMode(showOptions?.immersiveModeEnabled);
321321
}
322322
const ref = new WeakRef(this);
323-
org.nativescript.firebase.admob.FirebaseAdmob.RewardedInterstitialAd.show(
323+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.RewardedInterstitialAd.show(
324324
Application.android.foregroundActivity || Application.android.startActivity,
325325
this.native,
326-
new org.nativescript.firebase.admob.FirebaseAdmob.Callback<com.google.android.gms.ads.rewarded.RewardItem>({
326+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.Callback<com.google.android.gms.ads.rewarded.RewardItem>({
327327
onSuccess(reward): void {
328328
ref.get()?._onAdEvent?.(RewardedAdEventType.EARNED_REWARD, null, RewardedItem.fromNative(reward));
329329
},
@@ -392,11 +392,11 @@ export class RewardedAd implements IRewardedAd {
392392

393393
load(): void {
394394
const ref = new WeakRef(this);
395-
this._nativeRequest = org.nativescript.firebase.admob.FirebaseAdmob.RewardedAd.load(
395+
this._nativeRequest = org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.RewardedAd.load(
396396
Application.android.foregroundActivity || Application.android.startActivity,
397397
this.adUnitId,
398398
JSON.stringify(this._requestOptions || {}),
399-
new org.nativescript.firebase.admob.FirebaseAdmob.AdCallback({
399+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdCallback({
400400
onEvent(event: string, dataOrError: any) {
401401
const owner = ref.get?.();
402402
if (!owner) {
@@ -445,10 +445,10 @@ export class RewardedAd implements IRewardedAd {
445445
this.native.setImmersiveMode(showOptions?.immersiveModeEnabled);
446446
}
447447
const ref = new WeakRef(this);
448-
org.nativescript.firebase.admob.FirebaseAdmob.RewardedAd.show(
448+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.RewardedAd.show(
449449
Application.android.foregroundActivity || Application.android.startActivity,
450450
this.native,
451-
new org.nativescript.firebase.admob.FirebaseAdmob.Callback<com.google.android.gms.ads.rewarded.RewardItem>({
451+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.Callback<com.google.android.gms.ads.rewarded.RewardItem>({
452452
onSuccess(reward): void {
453453
ref.get()?._onAdEvent?.(RewardedAdEventType.EARNED_REWARD, null, RewardedItem.fromNative(reward));
454454
},
@@ -522,7 +522,6 @@ const MEDIUM_RECTANGLE = lazy(() => com.google.android.gms.ads.AdSize.MEDIUM_REC
522522

523523
const FLUID = lazy(() => com.google.android.gms.ads.AdSize.FLUID);
524524
const WIDE_SKYSCRAPER = lazy(() => com.google.android.gms.ads.AdSize.WIDE_SKYSCRAPER);
525-
const SEARCH = lazy(() => com.google.android.gms.ads.AdSize.SEARCH);
526525
const INVALID = lazy(() => com.google.android.gms.ads.AdSize.INVALID);
527526
const FULL_WIDTH = lazy(() => com.google.android.gms.ads.AdSize.FULL_WIDTH);
528527
const AUTO_HEIGHT = lazy(() => com.google.android.gms.ads.AdSize.AUTO_HEIGHT);
@@ -604,10 +603,6 @@ export class BannerAdSize extends BannerAdSizeBase {
604603
return BannerAdSize.fromNative(INVALID());
605604
}
606605

607-
static get SEARCH(): BannerAdSize {
608-
return BannerAdSize.fromNative(SEARCH());
609-
}
610-
611606
get native() {
612607
return this._native;
613608
}
@@ -646,7 +641,7 @@ export class BannerAd extends BannerAdBase {
646641

647642
load(options?: RequestOptions) {
648643
if (this._native) {
649-
this._nativeRequest = org.nativescript.firebase.admob.FirebaseAdmob.BannerAd.load(JSON.stringify(options || {}), this._native);
644+
this._nativeRequest = org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.BannerAd.load(JSON.stringify(options || {}), this._native);
650645
}
651646
}
652647

@@ -670,7 +665,7 @@ export class MobileAds implements IMobileAds {
670665
onInitializationComplete(status: com.google.android.gms.ads.initialization.InitializationStatus) {
671666
let data = {};
672667
try {
673-
data = JSON.parse(org.nativescript.firebase.admob.FirebaseAdmob.toJSONStatusMap(status.getAdapterStatusMap()));
668+
data = JSON.parse(org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.toJSONStatusMap(status.getAdapterStatusMap()));
674669
} catch (e) {
675670
// noop
676671
}
@@ -699,7 +694,7 @@ export class MobileAds implements IMobileAds {
699694
} else {
700695
parsedConfiguration.tagForUnderAgeOfConsent = 'unspecified';
701696
}
702-
org.nativescript.firebase.admob.FirebaseAdmob.setRequestConfiguration(JSON.stringify(requestConfiguration));
697+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.setRequestConfiguration(JSON.stringify(requestConfiguration));
703698
} catch (e) {
704699
// noop
705700
}

packages/google-mobile-ads/index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ export declare class BannerAdSize extends BannerAdSizeBase {
199199

200200
static readonly INVALID: BannerAdSize;
201201

202-
static readonly SEARCH: BannerAdSize;
203-
204202
static createAnchoredAdaptiveBanner(width: number, orientation: 'portrait' | 'landscape' | 'device'): BannerAdSize;
205203

206204
static createInLineAdaptiveBanner(width: number, maxHeight: number, orientation: 'portrait' | 'landscape' | 'device'): BannerAdSize;

packages/google-mobile-ads/index.ios.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -350,23 +350,23 @@ export class BannerAdSize extends BannerAdSizeBase {
350350
}
351351

352352
static get BANNER(): BannerAdSize {
353-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.Banner));
353+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.Banner));
354354
}
355355

356356
static get FULL_BANNER(): BannerAdSize {
357-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.FullBanner));
357+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.FullBanner));
358358
}
359359

360360
static get LARGE_BANNER(): BannerAdSize {
361-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.LargeBanner));
361+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.LargeBanner));
362362
}
363363

364364
static get LEADERBOARD(): BannerAdSize {
365-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.LeaderBoard));
365+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.LeaderBoard));
366366
}
367367

368368
static get MEDIUM_RECTANGLE(): BannerAdSize {
369-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.MediumRectangle));
369+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.MediumRectangle));
370370
}
371371

372372
static createAnchoredAdaptiveBanner(width: number, orientation: 'portrait' | 'landscape' | 'device' = 'device'): BannerAdSize {
@@ -377,7 +377,7 @@ export class BannerAdSize extends BannerAdSizeBase {
377377
nativeOrientation = Orientation.Landscape;
378378
}
379379

380-
return BannerAdSize.fromNative(TNSGA.createAnchoredAdaptiveBanner(width, nativeOrientation));
380+
return BannerAdSize.fromNative(NSCGA.createAnchoredAdaptiveBanner(width, nativeOrientation));
381381
}
382382

383383
static createInLineAdaptiveBanner(width: number, maxHeight: number = 0, orientation: 'portrait' | 'landscape' | 'device' = 'device'): BannerAdSize {
@@ -388,24 +388,19 @@ export class BannerAdSize extends BannerAdSizeBase {
388388
nativeOrientation = Orientation.Landscape;
389389
}
390390

391-
return BannerAdSize.fromNative(TNSGA.createInlineAdaptiveBanner(width, maxHeight, nativeOrientation));
391+
return BannerAdSize.fromNative(NSCGA.createInlineAdaptiveBanner(width, maxHeight, nativeOrientation));
392392
}
393393

394394
static get FLUID(): BannerAdSize {
395-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.Fluid));
395+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.Fluid));
396396
}
397397

398398
static get WIDE_SKYSCRAPER(): BannerAdSize {
399-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.WideSkyScraper));
399+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.WideSkyScraper));
400400
}
401401

402402
static get INVALID(): BannerAdSize {
403-
return BannerAdSize.fromNative(TNSGA.createBanner(NSCGABannersSize.Invalid));
404-
}
405-
406-
static get SEARCH(): BannerAdSize {
407-
console.error('BannerAdSize', 'SEARCH', 'not supported on iOS');
408-
return BannerAdSize.INVALID;
403+
return BannerAdSize.fromNative(NSCGA.createBanner(NSCGABannersSize.Invalid));
409404
}
410405

411406
get native() {

packages/google-mobile-ads/nativead/index.android.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ export class NativeAdLoader implements INativeAdLoader {
164164
load(): void;
165165
load(arg?: any): void {
166166
const ref = new WeakRef(this);
167-
this._native = org.nativescript.firebase.admob.FirebaseAdmob.NativeAd.createLoader(
167+
this._native = org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.NativeAd.createLoader(
168168
Application.android.foregroundActivity || Application.android.startActivity,
169169
this._adUnitId,
170170
JSON.stringify(this._nativeAdOptions || {}),
171-
new org.nativescript.firebase.admob.FirebaseAdmob.AdLoaderCallback({
171+
new org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.AdLoaderCallback({
172172
onEvent(event: string, param1: any): void {
173173
const owner = ref.get();
174174
let nativeAd: NativeAd;
@@ -206,14 +206,14 @@ export class NativeAdLoader implements INativeAdLoader {
206206
);
207207
if (arg) {
208208
if (typeof arg === 'number') {
209-
org.nativescript.firebase.admob.FirebaseAdmob.NativeAd.load(this._native, JSON.stringify(this._requestOptions), arg);
209+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.NativeAd.load(this._native, JSON.stringify(this._requestOptions), arg);
210210
}
211211

212212
if (typeof arg === 'object') {
213-
org.nativescript.firebase.admob.FirebaseAdmob.NativeAd.load(this._native, JSON.stringify(arg), true);
213+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.NativeAd.load(this._native, JSON.stringify(arg), true);
214214
}
215215
} else {
216-
org.nativescript.firebase.admob.FirebaseAdmob.NativeAd.load(this._native, JSON.stringify(this._requestOptions), false);
216+
org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.NativeAd.load(this._native, JSON.stringify(this._requestOptions), false);
217217
}
218218
}
219219

@@ -565,7 +565,7 @@ export class NativeAdImage implements INativeAdImage {
565565
}
566566

567567
get image() {
568-
return new ImageSource(org.nativescript.firebase.admob.FirebaseAdmob.getBitmap(this.native?.getDrawable?.() || null));
568+
return new ImageSource(org.nativescript.plugins.google_mobile_ads.GoogleMobileAds.getBitmap(this.native?.getDrawable?.() || null));
569569
}
570570

571571
get url(): string {

packages/google-mobile-ads/nativead/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class NativeAdLoader implements INativeAdLoader {
260260
options.push(numberOfAds);
261261
}
262262

263-
this._native = GADAdLoader.alloc().initWithAdUnitIDRootViewControllerAdTypesOptions(this._adUnitId, topViewController(), [TNSGA.AdLoaderAdTypeToString(NSCAdLoaderAdType.Native)], options);
263+
this._native = GADAdLoader.alloc().initWithAdUnitIDRootViewControllerAdTypesOptions(this._adUnitId, topViewController(), [NSCGA.AdLoaderAdTypeToString(NSCAdLoaderAdType.Native)], options);
264264
this._native.delegate = this._delegate;
265265

266266
if (arg) {

packages/google-mobile-ads/platforms/android/java/org/nativescript/firebase/admob/FirebaseAdmob.kt renamed to packages/google-mobile-ads/platforms/android/java/org/nativescript/plugins/google_mobile_ads/GoogleMobileAds.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.nativescript.firebase.admob
1+
package org.nativescript.plugins.google_mobile_ads
22

33
import android.app.Activity
44
import android.content.Context
@@ -104,7 +104,7 @@ private const val AD_IMPRESSION_EVENT = "adImpression"
104104
private const val AD_FAILED_TO_SHOW_FULL_SCREEN_CONTENT = " adFailedToShowFullScreenContent"
105105

106106

107-
class FirebaseAdmob {
107+
class GoogleMobileAds {
108108
interface Callback<T> {
109109
fun onSuccess(result: T?)
110110
fun onError(error: Any?)
@@ -279,8 +279,7 @@ class FirebaseAdmob {
279279
MEDIUM_RECTANGLE("MEDIUM_RECTANGLE"),
280280
SMART_BANNER("SMART_BANNER"),
281281
WIDE_SKYSCRAPER("WIDE_SKYSCRAPER"),
282-
INVALID("INVALID"),
283-
SEARCH("SEARCH");
282+
INVALID("INVALID");
284283

285284
override fun toString(): String {
286285
return value
@@ -296,7 +295,6 @@ class FirebaseAdmob {
296295
MEDIUM_RECTANGLE -> AdSize.MEDIUM_RECTANGLE
297296
SMART_BANNER -> AdSize.SMART_BANNER
298297
WIDE_SKYSCRAPER -> AdSize.WIDE_SKYSCRAPER
299-
SEARCH -> AdSize.SEARCH
300298
else -> AdSize.INVALID
301299
}
302300
}
@@ -312,7 +310,6 @@ class FirebaseAdmob {
312310
"MEDIUM_RECTANGLE" -> MEDIUM_RECTANGLE
313311
"SMART_BANNER" -> SMART_BANNER
314312
"WIDE_SKYSCRAPER" -> WIDE_SKYSCRAPER
315-
"SEARCH" -> SEARCH
316313
else -> INVALID
317314
}
318315
}

packages/google-mobile-ads/platforms/ios/src/TNSGA.swift renamed to packages/google-mobile-ads/platforms/ios/src/NSCGA.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Foundation
22
import GoogleMobileAds
33

44
@objcMembers
5-
@objc(TNSGA)
6-
public class TNSGA:NSObject {
5+
@objc(NSCGA)
6+
public class NSCGA:NSObject {
77

88
@objc(Orientation)
99
public enum Orientation:Int, RawRepresentable {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path="./android.d.ts" />
22
/// <reference path="./com.google.android.ump.d.ts" />
33
/// <reference path="./objc!GoogleMobileAds.d.ts" />
4-
/// <reference path="./objc!TNSGA.d.ts" />
4+
/// <reference path="./objc!NSCGA.d.ts" />
55
/// <reference path="./objc!UserMessagingPlatform.d.ts" />
6-
/// <reference path="./org.nativescript.firebase.admob.d.ts" />
6+
/// <reference path="./org.nativescript.plugins.google_mobile_ads.d.ts" />

packages/google-mobile-ads/typings/objc!TNSGA.d.ts renamed to packages/google-mobile-ads/typings/objc!NSCGA.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ declare const enum Orientation {
3232
Device = 2,
3333
}
3434

35-
declare class TNSGA extends NSObject {
36-
static alloc(): TNSGA; // inherited from NSObject
35+
declare class NSCGA extends NSObject {
36+
static alloc(): NSCGA; // inherited from NSObject
3737

3838
static createAnchoredAdaptiveBanner(width: number, orientation: Orientation): GADAdSize;
3939

4040
static createInlineAdaptiveBanner(width: number, maxHeight: number, orientation: Orientation): GADAdSize;
4141

4242
static AdLoaderAdTypeToString(type: NSCAdLoaderAdType): string;
4343

44-
static new(): TNSGA; // inherited from NSObject
44+
static new(): NSCGA; // inherited from NSObject
4545

4646
static createBanner(size: NSCGABannersSize): GADAdSize;
4747
}

0 commit comments

Comments
 (0)