From 9dc4686c50d83c557f227b3f5a02a41e207b318b Mon Sep 17 00:00:00 2001 From: Ngoc Nguyen Date: Fri, 2 Oct 2020 16:02:15 +0700 Subject: [PATCH 1/6] Fix #1683 NS7+Ng10 Admob Smartbanner error: Invalid ad width or height: (0, 0) on v11.0.0 --- src/admob/admob.ios.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/admob/admob.ios.ts b/src/admob/admob.ios.ts index 857be88a..6991f1f7 100644 --- a/src/admob/admob.ios.ts +++ b/src/admob/admob.ios.ts @@ -36,9 +36,15 @@ export function showBanner(arg: BannerOptions): Promise { const originX = (view.frame.size.width - adWidth) / 2; const originY = settings.margins.top > -1 ? settings.margins.top : (settings.margins.bottom > -1 ? view.frame.size.height - adHeight - settings.margins.bottom : 0.0); - const origin = CGPointMake(originX, originY); - firebase.admob.adView = GADBannerView.alloc().initWithAdSizeOrigin(bannerType, origin); + //Fix for the smart banner size on NS7.0+, due to issue with initWithAdSizeOrigin response "Invalid ad width or height: (0, 0)" + if (settings.size === AD_SIZE.SMART_BANNER) { + const adFrameRec = CGRectMake(originX, originY, adWidth, Math.min(adHeight, 50)); // minimum height should be 50 for a ad banner + firebase.admob.adView = GADBannerView.alloc().initWithFrame(adFrameRec) + } else { + const origin = CGPointMake(originX, originY); + firebase.admob.adView = GADBannerView.alloc().initWithAdSizeOrigin(bannerType, origin); + } firebase.admob.adView.adUnitID = settings.iosBannerId; const adRequest = GADRequest.request(); From 954e120c98bcf25738b7cb9f0831b0ad655c9a4f Mon Sep 17 00:00:00 2001 From: Ngoc Nguyen Date: Fri, 2 Oct 2020 18:15:59 +0700 Subject: [PATCH 2/6] #smart banner with calculated height --- src/admob/admob.ios.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admob/admob.ios.ts b/src/admob/admob.ios.ts index 6991f1f7..ed639091 100644 --- a/src/admob/admob.ios.ts +++ b/src/admob/admob.ios.ts @@ -39,7 +39,7 @@ export function showBanner(arg: BannerOptions): Promise { //Fix for the smart banner size on NS7.0+, due to issue with initWithAdSizeOrigin response "Invalid ad width or height: (0, 0)" if (settings.size === AD_SIZE.SMART_BANNER) { - const adFrameRec = CGRectMake(originX, originY, adWidth, Math.min(adHeight, 50)); // minimum height should be 50 for a ad banner + const adFrameRec = CGRectMake(originX, originY, adWidth, adHeight); firebase.admob.adView = GADBannerView.alloc().initWithFrame(adFrameRec) } else { const origin = CGPointMake(originX, originY); From ab5a35c7328dad9eb9be9a761f9edeeaa9db84a0 Mon Sep 17 00:00:00 2001 From: Ngoc Nguyen Date: Fri, 2 Oct 2020 19:02:06 +0700 Subject: [PATCH 3/6] #smart banner ad should not have height less than 50 --- src/admob/admob.ios.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admob/admob.ios.ts b/src/admob/admob.ios.ts index ed639091..4372bb74 100644 --- a/src/admob/admob.ios.ts +++ b/src/admob/admob.ios.ts @@ -39,7 +39,7 @@ export function showBanner(arg: BannerOptions): Promise { //Fix for the smart banner size on NS7.0+, due to issue with initWithAdSizeOrigin response "Invalid ad width or height: (0, 0)" if (settings.size === AD_SIZE.SMART_BANNER) { - const adFrameRec = CGRectMake(originX, originY, adWidth, adHeight); + const adFrameRec = CGRectMake(originX, originY, adWidth, Math.max(adHeight, 50)); // minimum height should be 50 for a ad banner firebase.admob.adView = GADBannerView.alloc().initWithFrame(adFrameRec) } else { const origin = CGPointMake(originX, originY); From 91672257b73ec3411dab864e027eac7dd8a34725 Mon Sep 17 00:00:00 2001 From: Ngoc Nguyen Date: Fri, 2 Oct 2020 19:03:04 +0700 Subject: [PATCH 4/6] #fix apple signin on NS7 --- src/firebase.ios.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/firebase.ios.ts b/src/firebase.ios.ts index 9a1f2a8e..9d37d1f2 100755 --- a/src/firebase.ios.ts +++ b/src/firebase.ios.ts @@ -947,12 +947,12 @@ firebase.login = arg => { appleIDRequest.nonce = sha256Nonce; const authorizationController = ASAuthorizationController.alloc().initWithAuthorizationRequests([appleIDRequest]); - const delegate = ASAuthorizationControllerDelegateImpl.createWithOwnerAndResolveReject(new WeakRef(this), resolve, reject); + const delegate = ASAuthorizationControllerDelegateImpl.createWithOwnerAndResolveReject(this, resolve, reject); CFRetain(delegate); authorizationController.delegate = delegate; authorizationController.presentationContextProvider = ASAuthorizationControllerPresentationContextProvidingImpl.createWithOwnerAndCallback( - new WeakRef(this)); + this); authorizationController.performRequests(); From 69a1be0bb844094eacae373f1e8bb6c1817cf80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=E1=BB=8Dc?= Date: Wed, 12 May 2021 14:50:28 +0700 Subject: [PATCH 5/6] #fea: support UserId,CustomData for admob SSV --- src/admob/admob.android.ts | 23 ++++++++++++++++------- src/admob/admob.d.ts | 8 ++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/admob/admob.android.ts b/src/admob/admob.android.ts index 23fa17fc..9bf5adc0 100644 --- a/src/admob/admob.android.ts +++ b/src/admob/admob.android.ts @@ -52,12 +52,12 @@ export function showBanner(arg: BannerOptions): Promise { firebase.admob.adView.loadAd(ad); const density = Utils.layout.getDisplayDensity(), - top = settings.margins.top * density, - bottom = settings.margins.bottom * density; + top = settings.margins.top * density, + bottom = settings.margins.bottom * density; const relativeLayoutParams = new android.widget.RelativeLayout.LayoutParams( - android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, - android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); + android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, + android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); if (bottom > -1) { relativeLayoutParams.bottomMargin = bottom; @@ -73,8 +73,8 @@ export function showBanner(arg: BannerOptions): Promise { adViewLayout.addView(firebase.admob.adView, relativeLayoutParams); const relativeLayoutParamsOuter = new android.widget.RelativeLayout.LayoutParams( - android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, - android.widget.RelativeLayout.LayoutParams.MATCH_PARENT); + android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, + android.widget.RelativeLayout.LayoutParams.MATCH_PARENT); // Wrapping it in a timeout makes sure that when this function is loaded from a Page.loaded event 'frame.Frame.topmost()' doesn't resolve to 'undefined'. // Also, in NativeScript 4+ it may be undefined anyway.. so using the appModule in that case. @@ -192,7 +192,16 @@ export function preloadRewardedVideoAd(arg: PreloadRewardedVideoAdOptions): Prom const settings = firebase.merge(arg, BANNER_DEFAULTS); const activity = Application.android.foregroundActivity || Application.android.startActivity; firebase.admob.rewardedAdVideoView = com.google.android.gms.ads.MobileAds.getRewardedVideoAdInstance(activity); - + + if (firebase.admob.rewardedAdVideoView) { + //https://developers.google.com/admob/android/ssv#ssv_callback_parameters + if (settings.userId) { + firebase.admob.rewardedAdVideoView.setUserId(settings.userId); + } + if (settings.customData) { + firebase.admob.rewardedAdVideoView.setUserId(settings.customData); + } + } rewardedVideoCallbacks.onLoaded = resolve; rewardedVideoCallbacks.onFailedToLoad = reject; diff --git a/src/admob/admob.d.ts b/src/admob/admob.d.ts index 3a2887e4..f827c69d 100644 --- a/src/admob/admob.d.ts +++ b/src/admob/admob.d.ts @@ -131,6 +131,14 @@ export interface InterstitialOptions extends AdLifeCycleEvents { } export interface PreloadRewardedVideoAdOptions { + /** + * for user_id of https://developers.google.com/admob/ios/ssv#ssv_callback_parameters or https://developers.google.com/admob/android/ssv#ssv_callback_parameters + */ + userId?:string; + /** + * for custom_data of https://developers.google.com/admob/ios/ssv#ssv_callback_parameters or https://developers.google.com/admob/android/ssv#ssv_callback_parameters + */ + customData?:string; /** * When true you'll use googles testing iosAdPlacementId and androidAdPlacementId. */ From c7f6dc36fe4f8013a1c3ebe3c6cecac58b00479d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=E1=BB=8Dc?= Date: Wed, 12 May 2021 15:38:31 +0700 Subject: [PATCH 6/6] #Admob server SSV callback android+ios --- src/admob/admob.android.ts | 2 +- src/admob/admob.ios.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/admob/admob.android.ts b/src/admob/admob.android.ts index 9bf5adc0..985eba7c 100644 --- a/src/admob/admob.android.ts +++ b/src/admob/admob.android.ts @@ -199,7 +199,7 @@ export function preloadRewardedVideoAd(arg: PreloadRewardedVideoAdOptions): Prom firebase.admob.rewardedAdVideoView.setUserId(settings.userId); } if (settings.customData) { - firebase.admob.rewardedAdVideoView.setUserId(settings.customData); + firebase.admob.rewardedAdVideoView.setCustomData(settings.customData); } } rewardedVideoCallbacks.onLoaded = resolve; diff --git a/src/admob/admob.ios.ts b/src/admob/admob.ios.ts index 8c78d8bc..333038f4 100644 --- a/src/admob/admob.ios.ts +++ b/src/admob/admob.ios.ts @@ -224,10 +224,23 @@ export function preloadRewardedVideoAd(arg: PreloadRewardedVideoAdOptions): Prom firebase.admob.rewardedAdVideoView = GADRewardBasedVideoAd.sharedInstance(); firebase.admob.rewardedAdVideoView.delegate = _rewardBasedVideoAdDelegate; + const settings = firebase.merge(arg, BANNER_DEFAULTS); - const adRequest = GADRequest.request(); + + + if (firebase.admob.rewardedAdVideoView) { + //https://developers.google.com/admob/ios/ssv#ssv_callback_parameters + if (settings.userId) { + firebase.admob.rewardedAdVideoView.userIdentifier = settings.userId; + } + if (settings.customData) { + firebase.admob.rewardedAdVideoView.customRewardString = settings.customData; + } + } + const adRequest = GADRequest.request(); + if (settings.testing) { let testDevices: any = []; try {