@capacitor-community/admob 7.0.3 → 7.1.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
15
15
  s.swift_version = '5.1'
16
16
  s.static_framework = true
17
17
  s.dependency 'Capacitor'
18
- s.dependency 'Google-Mobile-Ads-SDK', '11.3.0'
19
- s.dependency 'GoogleUserMessagingPlatform', '>= 2.7.0', '< 3.0.0'
18
+ s.dependency 'Google-Mobile-Ads-SDK', '12.7.0'
19
+ s.dependency 'GoogleUserMessagingPlatform', '3.0.0'
20
20
  end
package/Package.swift CHANGED
@@ -11,7 +11,7 @@ let package = Package(
11
11
  ],
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"),
14
- .package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", from: "11.3.0")
14
+ .package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", from: "12.7.0")
15
15
  ],
16
16
  targets: [
17
17
  .target(
@@ -4,12 +4,12 @@ ext {
4
4
  androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
5
5
  androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
6
6
  androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
7
- playServicesAdsVersion = project.hasProperty('playServicesAdsVersion') ? rootProject.ext.playServicesAdsVersion : '23.0.0'
7
+ playServicesAdsVersion = project.hasProperty('playServicesAdsVersion') ? rootProject.ext.playServicesAdsVersion : '24.4.+'
8
8
  androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.13.0'
9
9
  }
10
10
 
11
11
  buildscript {
12
- ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.25'
12
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.1.0'
13
13
  repositories {
14
14
  google()
15
15
  mavenCentral()
@@ -102,6 +102,22 @@ public class BannerExecutor extends Executor {
102
102
  break;
103
103
  }
104
104
 
105
+ // set Safe Area
106
+ View rootView = activitySupplier.get().getWindow().getDecorView();
107
+ rootView.setOnApplyWindowInsetsListener((v, insets) -> {
108
+ int bottomInset = insets.getSystemWindowInsetBottom();
109
+ int topInset = insets.getSystemWindowInsetTop();
110
+
111
+ if ("TOP_CENTER".equals(adOptions.position)) {
112
+ mAdViewLayoutParams.setMargins(0, topInset, 0, 0);
113
+ } else {
114
+ mAdViewLayoutParams.setMargins(0, 0, 0, bottomInset);
115
+ }
116
+
117
+ mAdViewLayout.setLayoutParams(mAdViewLayoutParams);
118
+ return insets;
119
+ });
120
+
105
121
  mAdViewLayout.setLayoutParams(mAdViewLayoutParams);
106
122
 
107
123
  int densityMargin = (int) (adOptions.margin * density);
@@ -25,7 +25,9 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
25
25
  CAPPluginMethod(name: "prepareInterstitial", returnType: CAPPluginReturnPromise),
26
26
  CAPPluginMethod(name: "showInterstitial", returnType: CAPPluginReturnPromise),
27
27
  CAPPluginMethod(name: "prepareRewardVideoAd", returnType: CAPPluginReturnPromise),
28
- CAPPluginMethod(name: "showRewardVideoAd", returnType: CAPPluginReturnPromise)
28
+ CAPPluginMethod(name: "showRewardVideoAd", returnType: CAPPluginReturnPromise),
29
+ CAPPluginMethod(name: "prepareRewardInterstitialAd", returnType: CAPPluginReturnPromise),
30
+ CAPPluginMethod(name: "showRewardInterstitialAd", returnType: CAPPluginReturnPromise)
29
31
  ]
30
32
 
31
33
  var testingDevices: [String] = []
@@ -49,7 +51,7 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
49
51
  self.consentExecutor.plugin = self
50
52
  self.setRequestConfiguration(call)
51
53
 
52
- GADMobileAds.sharedInstance().start(completionHandler: nil)
54
+ MobileAds.shared.start(completionHandler: nil)
53
55
  call.resolve([:])
54
56
  }
55
57
 
@@ -72,7 +74,7 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
72
74
 
73
75
  @objc func setApplicationMuted(_ call: CAPPluginCall) {
74
76
  if let shouldMute = call.getBool("muted") {
75
- GADMobileAds.sharedInstance().applicationMuted = shouldMute
77
+ MobileAds.shared.isApplicationMuted = shouldMute
76
78
  call.resolve([:])
77
79
  } else {
78
80
  call.reject("muted property cannot be null")
@@ -85,7 +87,7 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
85
87
  // Clamp volumes.
86
88
  if volume < 0.0 {volume = 0.0} else if volume > 1.0 {volume = 1.0}
87
89
 
88
- GADMobileAds.sharedInstance().applicationVolume = volume
90
+ MobileAds.shared.applicationVolume = volume
89
91
 
90
92
  call.resolve([:])
91
93
  } else {
@@ -252,11 +254,11 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
252
254
  return adUnitID
253
255
  }
254
256
 
255
- private func GADRequestWithOption(_ npa: Bool) -> GADRequest {
256
- let request = GADRequest()
257
+ private func GADRequestWithOption(_ npa: Bool) -> Request {
258
+ let request = Request()
257
259
 
258
260
  if npa {
259
- let extras = GADExtras()
261
+ let extras = Extras()
260
262
  extras.additionalParameters = ["npa": "1"]
261
263
  request.register(extras)
262
264
  }
@@ -270,30 +272,30 @@ public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
270
272
  private func setRequestConfiguration(_ call: CAPPluginCall) {
271
273
 
272
274
  if call.getBool("initializeForTesting") ?? false {
273
- GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = call.getArray("testingDevices", String.self) ?? []
275
+ MobileAds.shared.requestConfiguration.testDeviceIdentifiers = call.getArray("testingDevices", String.self) ?? []
274
276
  }
275
277
 
276
278
  if call.getBool("tagForChildDirectedTreatment") == true {
277
- GADMobileAds.sharedInstance().requestConfiguration.tagForChildDirectedTreatment = true
279
+ MobileAds.shared.requestConfiguration.tagForChildDirectedTreatment = true
278
280
  }
279
281
 
280
282
  if call.getBool("tagForUnderAgeOfConsent") == true {
281
- GADMobileAds.sharedInstance().requestConfiguration.tagForUnderAgeOfConsent = true
283
+ MobileAds.shared.requestConfiguration.tagForUnderAgeOfConsent = true
282
284
  }
283
285
 
284
286
  if call.getString("maxAdContentRating") != nil {
285
287
  switch call.getString("maxAdContentRating") {
286
288
  case "General":
287
- GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =
289
+ MobileAds.shared.requestConfiguration.maxAdContentRating =
288
290
  GADMaxAdContentRating.general
289
291
  case "ParentalGuidance":
290
- GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =
292
+ MobileAds.shared.requestConfiguration.maxAdContentRating =
291
293
  GADMaxAdContentRating.parentalGuidance
292
294
  case "Teen":
293
- GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =
295
+ MobileAds.shared.requestConfiguration.maxAdContentRating =
294
296
  GADMaxAdContentRating.teen
295
297
  case "MatureAudience":
296
- GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =
298
+ MobileAds.shared.requestConfiguration.maxAdContentRating =
297
299
  GADMaxAdContentRating.matureAudience
298
300
  default:
299
301
  print("maxAdContentRating can't find value")
@@ -2,34 +2,36 @@ import Foundation
2
2
  import Capacitor
3
3
  import GoogleMobileAds
4
4
 
5
- class BannerExecutor: NSObject, GADBannerViewDelegate {
5
+ class BannerExecutor: NSObject, BannerViewDelegate {
6
6
  weak var plugin: AdMobPlugin?
7
- var bannerView: GADBannerView!
7
+ var bannerView: BannerView!
8
+ var adPosition: String = ""
9
+ var Margin: Int = 0
8
10
 
9
- func showBanner(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
11
+ func showBanner(_ call: CAPPluginCall, _ request: Request, _ adUnitID: String) {
10
12
  if let rootViewController = plugin?.getRootVC() {
11
13
 
12
14
  let adSize = call.getString("adSize") ?? "ADAPTIVE_BANNER"
13
15
  let adPosition = call.getString("position") ?? "BOTTOM_CENTER"
14
16
  let adMargin = call.getInt("margin") ?? 0
15
17
 
16
- var bannerSize: GADAdSize
18
+ var bannerSize: AdSize
17
19
 
18
20
  switch adSize {
19
21
  case "BANNER":
20
- bannerSize = GADAdSizeBanner
22
+ bannerSize = AdSizeBanner
21
23
  break
22
24
  case "LARGE_BANNER":
23
- bannerSize = GADAdSizeLargeBanner
25
+ bannerSize = AdSizeLargeBanner
24
26
  break
25
27
  case "FULL_BANNER":
26
- bannerSize = GADAdSizeFullBanner
28
+ bannerSize = AdSizeFullBanner
27
29
  break
28
30
  case "LEADERBOARD":
29
- bannerSize = GADAdSizeLeaderboard
31
+ bannerSize = AdSizeLeaderboard
30
32
  break
31
33
  case "MEDIUM_RECTANGLE":
32
- bannerSize = GADAdSizeMediumRectangle
34
+ bannerSize = AdSizeMediumRectangle
33
35
  break
34
36
  case "SMART_BANNER":
35
37
  bannerSize = kGADAdSizeSmartBannerPortrait
@@ -45,11 +47,11 @@ class BannerExecutor: NSObject, GADBannerViewDelegate {
45
47
  }
46
48
  }()
47
49
  let viewWidth = frame.size.width
48
- bannerSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)
50
+ bannerSize = currentOrientationAnchoredAdaptiveBanner(width: viewWidth)
49
51
  break
50
52
  }
51
53
 
52
- self.bannerView = GADBannerView(adSize: bannerSize)
54
+ self.bannerView = BannerView(adSize: bannerSize)
53
55
  self.addBannerViewToView(self.bannerView, adPosition, adMargin)
54
56
  self.bannerView.translatesAutoresizingMaskIntoConstraints = false
55
57
  self.bannerView.adUnitID = adUnitID
@@ -107,22 +109,38 @@ class BannerExecutor: NSObject, GADBannerViewDelegate {
107
109
  call.resolve([:])
108
110
  }
109
111
 
110
- private func addBannerViewToView(_ bannerView: GADBannerView, _ adPosition: String, _ Margin: Int) {
112
+ private func addBannerViewToView(_ bannerView: BannerView, _ adPosition: String, _ Margin: Int) {
111
113
  removeBannerViewToView()
114
+ bannerView.translatesAutoresizingMaskIntoConstraints = false
115
+ bannerView.tag = 2743243288699 // rand
116
+ self.Margin = Margin
117
+ self.adPosition = adPosition
118
+ }
119
+
120
+ private func removeBannerViewToView() {
112
121
  if let rootViewController = plugin?.getRootVC() {
122
+ if let subView = rootViewController.view.viewWithTag(2743243288699) {
123
+ bannerView.delegate = nil
124
+ NSLog("AdMob: find subView")
125
+ subView.removeFromSuperview()
126
+ }
127
+ }
128
+ }
113
129
 
114
- bannerView.translatesAutoresizingMaskIntoConstraints = false
115
- bannerView.tag = 2743243288699 // rand
130
+ /// Tells the delegate an ad request loaded an ad.
131
+ func bannerViewDidReceiveAd(_ bannerView: BannerView) {
132
+ NSLog("bannerViewDidReceiveAd")
133
+ if let rootViewController = plugin?.getRootVC() {
116
134
  rootViewController.view.addSubview(bannerView)
117
135
  rootViewController.view.addConstraints(
118
136
  [NSLayoutConstraint(item: bannerView,
119
- attribute: adPosition == "TOP_CENTER" ? .top : .bottom,
137
+ attribute: self.adPosition == "TOP_CENTER" ? .top : .bottom,
120
138
  relatedBy: .equal,
121
139
  toItem: rootViewController.view.safeAreaLayoutGuide,
122
- attribute: adPosition == "TOP_CENTER" ? .top : .bottom,
140
+ attribute: self.adPosition == "TOP_CENTER" ? .top : .bottom,
123
141
  multiplier: 1,
124
- constant: CGFloat(Int(Margin) * -1)),
125
- NSLayoutConstraint(item: bannerView,
142
+ constant: CGFloat(Int(self.Margin) * -1)),
143
+ NSLayoutConstraint(item: bannerView,
126
144
  attribute: .centerX,
127
145
  relatedBy: .equal,
128
146
  toItem: rootViewController.view,
@@ -130,32 +148,17 @@ class BannerExecutor: NSObject, GADBannerViewDelegate {
130
148
  multiplier: 1,
131
149
  constant: 0)
132
150
  ])
133
- }
134
- }
151
+ self.plugin?.notifyListeners(BannerAdPluginEvents.SizeChanged.rawValue, data: [
152
+ "width": bannerView.frame.width,
153
+ "height": bannerView.frame.height
154
+ ])
155
+ self.plugin?.notifyListeners(BannerAdPluginEvents.Loaded.rawValue, data: [:])
135
156
 
136
- private func removeBannerViewToView() {
137
- if let rootViewController = plugin?.getRootVC() {
138
- if let subView = rootViewController.view.viewWithTag(2743243288699) {
139
- bannerView.delegate = nil
140
- NSLog("AdMob: find subView")
141
- subView.removeFromSuperview()
142
- }
143
157
  }
144
158
  }
145
159
 
146
- /// Tells the delegate an ad request loaded an ad.
147
- func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
148
- NSLog("bannerViewDidReceiveAd")
149
-
150
- self.plugin?.notifyListeners(BannerAdPluginEvents.SizeChanged.rawValue, data: [
151
- "width": bannerView.frame.width,
152
- "height": bannerView.frame.height
153
- ])
154
- self.plugin?.notifyListeners(BannerAdPluginEvents.Loaded.rawValue, data: [:])
155
- }
156
-
157
160
  /// Tells the delegate an ad request failed.
158
- func bannerView(_ bannerView: GADBannerView,
161
+ func bannerView(_ bannerView: BannerView,
159
162
  didFailToReceiveAdWithError error: Error) {
160
163
  NSLog("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
161
164
  self.removeBannerViewToView()
@@ -169,18 +172,18 @@ class BannerExecutor: NSObject, GADBannerViewDelegate {
169
172
  ])
170
173
  }
171
174
 
172
- func bannerViewDidRecordImpression(_ bannerView: GADBannerView) {
175
+ func bannerViewDidRecordImpression(_ bannerView: BannerView) {
173
176
  self.plugin?.notifyListeners(BannerAdPluginEvents.AdImpression.rawValue, data: [:])
174
177
  }
175
178
 
176
179
  /// Tells the delegate that a full-screen view will be presented in response
177
180
  /// to the user clicking on an ad.
178
- func bannerViewWillPresentScreen(_ bannerView: GADBannerView) {
181
+ func bannerViewWillPresentScreen(_ bannerView: BannerView) {
179
182
  self.plugin?.notifyListeners(BannerAdPluginEvents.Opened.rawValue, data: [:])
180
183
  }
181
184
 
182
185
  /// Tells the delegate that the full-screen view will be dismissed.
183
- func bannerViewWillDismissScreen(_ bannerView: GADBannerView) {
186
+ func bannerViewWillDismissScreen(_ bannerView: BannerView) {
184
187
  self.plugin?.notifyListeners(BannerAdPluginEvents.Closed.rawValue, data: [:])
185
188
  }
186
189
  }
@@ -7,25 +7,25 @@ class ConsentExecutor: NSObject {
7
7
  weak var plugin: AdMobPlugin?
8
8
 
9
9
  func requestConsentInfo(_ call: CAPPluginCall, _ debugGeography: Int, _ testDeviceIdentifiers: [String], _ tagForUnderAgeOfConsent: Bool) {
10
- let parameters = UMPRequestParameters()
11
- let debugSettings = UMPDebugSettings()
10
+ let parameters = RequestParameters()
11
+ let debugSettings = DebugSettings()
12
12
 
13
- debugSettings.geography = UMPDebugGeography(rawValue: debugGeography) ?? UMPDebugGeography.disabled
13
+ debugSettings.geography = DebugGeography(rawValue: debugGeography) ?? DebugGeography.disabled
14
14
  debugSettings.testDeviceIdentifiers = testDeviceIdentifiers
15
15
 
16
16
  parameters.debugSettings = debugSettings
17
- parameters.tagForUnderAgeOfConsent = tagForUnderAgeOfConsent
17
+ parameters.isTaggedForUnderAgeOfConsent = tagForUnderAgeOfConsent
18
18
 
19
19
  // Request an update to the consent information.
20
- UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
20
+ ConsentInformation.shared.requestConsentInfoUpdate(
21
21
  with: parameters,
22
22
  completionHandler: { error in
23
23
  if error != nil {
24
24
  call.reject("Request consent info failed")
25
25
  } else {
26
26
  call.resolve([
27
- "status": self.getConsentStatusString(UMPConsentInformation.sharedInstance.consentStatus),
28
- "isConsentFormAvailable": UMPConsentInformation.sharedInstance.formStatus == UMPFormStatus.available
27
+ "status": self.getConsentStatusString(ConsentInformation.shared.consentStatus),
28
+ "isConsentFormAvailable": ConsentInformation.shared.formStatus == FormStatus.available
29
29
  ])
30
30
  }
31
31
  })
@@ -33,16 +33,16 @@ class ConsentExecutor: NSObject {
33
33
 
34
34
  func showConsentForm(_ call: CAPPluginCall) {
35
35
  if let rootViewController = plugin?.getRootVC() {
36
- let formStatus = UMPConsentInformation.sharedInstance.formStatus
36
+ let formStatus = ConsentInformation.shared.formStatus
37
37
 
38
- if formStatus == UMPFormStatus.available {
39
- UMPConsentForm.load(completionHandler: {form, loadError in
38
+ if formStatus == FormStatus.available {
39
+ ConsentForm.load(with: {form, loadError in
40
40
  if loadError != nil {
41
41
  call.reject(loadError?.localizedDescription ?? "Load consent form error")
42
42
  return
43
43
  }
44
44
 
45
- if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required {
45
+ if ConsentInformation.shared.consentStatus == ConsentStatus.required {
46
46
  form?.present(from: rootViewController, completionHandler: { dismissError in
47
47
  if dismissError != nil {
48
48
  call.reject(dismissError?.localizedDescription ?? "Consent dismiss error")
@@ -50,12 +50,12 @@ class ConsentExecutor: NSObject {
50
50
  }
51
51
 
52
52
  call.resolve([
53
- "status": self.getConsentStatusString(UMPConsentInformation.sharedInstance.consentStatus)
53
+ "status": self.getConsentStatusString(ConsentInformation.shared.consentStatus)
54
54
  ])
55
55
  })
56
56
  } else {
57
57
  call.resolve([
58
- "status": self.getConsentStatusString(UMPConsentInformation.sharedInstance.consentStatus)
58
+ "status": self.getConsentStatusString(ConsentInformation.shared.consentStatus)
59
59
  ])
60
60
  }
61
61
  })
@@ -68,17 +68,17 @@ class ConsentExecutor: NSObject {
68
68
  }
69
69
 
70
70
  func resetConsentInfo(_ call: CAPPluginCall) {
71
- UMPConsentInformation.sharedInstance.reset()
71
+ ConsentInformation.shared.reset()
72
72
  call.resolve()
73
73
  }
74
74
 
75
- func getConsentStatusString(_ consentStatus: UMPConsentStatus) -> String {
75
+ func getConsentStatusString(_ consentStatus: ConsentStatus) -> String {
76
76
  switch consentStatus {
77
- case UMPConsentStatus.required:
77
+ case ConsentStatus.required:
78
78
  return "REQUIRED"
79
- case UMPConsentStatus.notRequired:
79
+ case ConsentStatus.notRequired:
80
80
  return "NOT_REQUIRED"
81
- case UMPConsentStatus.obtained:
81
+ case ConsentStatus.obtained:
82
82
  return "OBTAINED"
83
83
  default:
84
84
  return "UNKNOWN"
@@ -2,13 +2,13 @@ import Foundation
2
2
  import Capacitor
3
3
  import GoogleMobileAds
4
4
 
5
- class AdInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
5
+ class AdInterstitialExecutor: NSObject, FullScreenContentDelegate {
6
6
  weak var plugin: AdMobPlugin?
7
- var interstitial: GADInterstitialAd!
7
+ var interstitial: InterstitialAd!
8
8
 
9
- func prepareInterstitial(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
10
- GADInterstitialAd.load(
11
- withAdUnitID: adUnitID,
9
+ func prepareInterstitial(_ call: CAPPluginCall, _ request: Request, _ adUnitID: String) {
10
+ InterstitialAd.load(
11
+ with: adUnitID,
12
12
  request: request,
13
13
  completionHandler: { (ad, error) in
14
14
  if let error = error {
@@ -36,7 +36,7 @@ class AdInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
36
36
  func showInterstitial(_ call: CAPPluginCall) {
37
37
  if let rootViewController = plugin?.getRootVC() {
38
38
  if let ad = self.interstitial {
39
- ad.present(fromRootViewController: rootViewController)
39
+ ad.present(from: rootViewController)
40
40
  call.resolve([:])
41
41
  } else {
42
42
  NSLog("Ad wasn't ready")
@@ -45,7 +45,7 @@ class AdInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
45
45
  }
46
46
  }
47
47
 
48
- func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
48
+ func ad(_ ad: FullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
49
49
  NSLog("InterstitialFullScreenDelegate Ad failed to present full screen content with error \(error.localizedDescription).")
50
50
  self.plugin?.notifyListeners(InterstitialAdPluginEvents.FailedToShow.rawValue, data: [
51
51
  "code": 0,
@@ -53,12 +53,12 @@ class AdInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
53
53
  ])
54
54
  }
55
55
 
56
- func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
56
+ func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) {
57
57
  NSLog("InterstitialFullScreenDelegate Ad did present full screen content.")
58
58
  self.plugin?.notifyListeners(InterstitialAdPluginEvents.Showed.rawValue, data: [:])
59
59
  }
60
60
 
61
- func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
61
+ func adDidDismissFullScreenContent(_ ad: FullScreenPresentingAd) {
62
62
  NSLog("InterstitialFullScreenDelegate Ad did dismiss full screen content.")
63
63
  self.plugin?.notifyListeners(InterstitialAdPluginEvents.Dismissed.rawValue, data: [:])
64
64
  }
@@ -2,13 +2,13 @@ import Foundation
2
2
  import Capacitor
3
3
  import GoogleMobileAds
4
4
 
5
- class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
5
+ class AdRewardExecutor: NSObject, FullScreenContentDelegate {
6
6
  weak var plugin: AdMobPlugin?
7
- var rewardedAd: GADRewardedAd!
7
+ var rewardedAd: RewardedAd!
8
8
 
9
- func prepareRewardVideoAd(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
10
- GADRewardedAd.load(
11
- withAdUnitID: adUnitID,
9
+ func prepareRewardVideoAd(_ call: CAPPluginCall, _ request: Request, _ adUnitID: String) {
10
+ RewardedAd.load(
11
+ with: adUnitID,
12
12
  request: request,
13
13
  completionHandler: { (ad, error) in
14
14
  if let error = error {
@@ -24,11 +24,11 @@ class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
24
24
  self.rewardedAd = ad
25
25
 
26
26
  if let providedOptions = call.getObject("ssv") {
27
- let ssvOptions = GADServerSideVerificationOptions()
27
+ let ssvOptions = ServerSideVerificationOptions()
28
28
 
29
29
  if let customData = providedOptions["customData"] as? String {
30
30
  NSLog("Sending Custom Data: \(customData) to SSV callback")
31
- ssvOptions.customRewardString = customData
31
+ ssvOptions.customRewardText = customData
32
32
  }
33
33
 
34
34
  if let userId = providedOptions["userId"] as? String {
@@ -53,7 +53,7 @@ class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
53
53
  func showRewardVideoAd(_ call: CAPPluginCall) {
54
54
  if let rootViewController = plugin?.getRootVC() {
55
55
  if let ad = self.rewardedAd {
56
- ad.present(fromRootViewController: rootViewController,
56
+ ad.present(from: rootViewController,
57
57
  userDidEarnRewardHandler: {
58
58
  let reward = ad.adReward
59
59
  self.plugin?.notifyListeners(RewardAdPluginEvents.Rewarded.rawValue, data: ["type": reward.type, "amount": reward.amount])
@@ -66,7 +66,7 @@ class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
66
66
  }
67
67
  }
68
68
 
69
- func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
69
+ func ad(_ ad: FullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
70
70
  NSLog("RewardFullScreenDelegate Ad failed to present full screen content with error \(error.localizedDescription).")
71
71
  self.plugin?.notifyListeners(RewardAdPluginEvents.FailedToShow.rawValue, data: [
72
72
  "code": 0,
@@ -74,12 +74,12 @@ class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
74
74
  ])
75
75
  }
76
76
 
77
- func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
77
+ func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) {
78
78
  NSLog("RewardFullScreenDelegate Ad did present full screen content.")
79
79
  self.plugin?.notifyListeners(RewardAdPluginEvents.Showed.rawValue, data: [:])
80
80
  }
81
81
 
82
- func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
82
+ func adDidDismissFullScreenContent(_ ad: FullScreenPresentingAd) {
83
83
  NSLog("RewardFullScreenDelegate Ad did dismiss full screen content.")
84
84
  self.plugin?.notifyListeners(RewardAdPluginEvents.Dismissed.rawValue, data: [:])
85
85
  }
@@ -2,13 +2,13 @@ import Foundation
2
2
  import Capacitor
3
3
  import GoogleMobileAds
4
4
 
5
- class AdRewardInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
5
+ class AdRewardInterstitialExecutor: NSObject, FullScreenContentDelegate {
6
6
  weak var plugin: AdMobPlugin?
7
- var rewardedInterstitialAd: GADRewardedInterstitialAd!
7
+ var rewardedInterstitialAd: RewardedInterstitialAd!
8
8
 
9
- func prepareRewardInterstitialAd(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
10
- GADRewardedInterstitialAd.load(
11
- withAdUnitID: adUnitID,
9
+ func prepareRewardInterstitialAd(_ call: CAPPluginCall, _ request: Request, _ adUnitID: String) {
10
+ RewardedInterstitialAd.load(
11
+ with: adUnitID,
12
12
  request: request,
13
13
  completionHandler: { (ad, error) in
14
14
  if let error = error {
@@ -24,11 +24,11 @@ class AdRewardInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
24
24
  self.rewardedInterstitialAd = ad
25
25
 
26
26
  if let providedOptions = call.getObject("ssv") {
27
- let ssvOptions = GADServerSideVerificationOptions()
27
+ let ssvOptions = ServerSideVerificationOptions()
28
28
 
29
29
  if let customData = providedOptions["customData"] as? String {
30
30
  NSLog("Sending Custom Data: \(customData) to SSV callback")
31
- ssvOptions.customRewardString = customData
31
+ ssvOptions.customRewardText = customData
32
32
  }
33
33
 
34
34
  if let userId = providedOptions["userId"] as? String {
@@ -53,7 +53,7 @@ class AdRewardInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
53
53
  func showRewardInterstitialAd(_ call: CAPPluginCall) {
54
54
  if let rootViewController = plugin?.getRootVC() {
55
55
  if let ad = self.rewardedInterstitialAd {
56
- ad.present(fromRootViewController: rootViewController,
56
+ ad.present(from: rootViewController,
57
57
  userDidEarnRewardHandler: {
58
58
  let reward = ad.adReward
59
59
  self.plugin?.notifyListeners(RewardInterstitialAdPluginEvents.Rewarded.rawValue, data: ["type": reward.type, "amount": reward.amount])
@@ -66,7 +66,7 @@ class AdRewardInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
66
66
  }
67
67
  }
68
68
 
69
- func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
69
+ func ad(_ ad: FullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
70
70
  NSLog("RewardFullScreenDelegate Ad failed to present full screen content with error \(error.localizedDescription).")
71
71
  self.plugin?.notifyListeners(RewardInterstitialAdPluginEvents.FailedToShow.rawValue, data: [
72
72
  "code": 0,
@@ -74,12 +74,12 @@ class AdRewardInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
74
74
  ])
75
75
  }
76
76
 
77
- func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
77
+ func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) {
78
78
  NSLog("RewardFullScreenDelegate Ad did present full screen content.")
79
79
  self.plugin?.notifyListeners(RewardInterstitialAdPluginEvents.Showed.rawValue, data: [:])
80
80
  }
81
81
 
82
- func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
82
+ func adDidDismissFullScreenContent(_ ad: FullScreenPresentingAd) {
83
83
  NSLog("RewardFullScreenDelegate Ad did dismiss full screen content.")
84
84
  self.plugin?.notifyListeners(RewardInterstitialAdPluginEvents.Dismissed.rawValue, data: [:])
85
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/admob",
3
- "version": "7.0.3",
3
+ "version": "7.1.0-1",
4
4
  "description": "A native plugin for AdMob",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",