react-native-google-mobile-ads 14.4.3 → 14.6.0

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.
Files changed (206) hide show
  1. package/README.md +3 -3
  2. package/__tests__/googleMobileAds.test.ts +1 -1
  3. package/__tests__/interstitial.test.ts +9 -23
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +0 -28
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.kt +13 -0
  6. package/ios/RNGoogleMobileAds/{common/RNJSON.h → RNGoogleMobileAdsAppOpenModule.h} +11 -9
  7. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.mm +100 -0
  8. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.h +4 -0
  9. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.mm +6 -1
  10. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +13 -2
  11. package/ios/RNGoogleMobileAds/{RNGoogleMobileAdsConsentModule.m → RNGoogleMobileAdsConsentModule.mm} +115 -26
  12. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.h +53 -0
  13. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.mm +220 -0
  14. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +36 -0
  15. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.mm +80 -0
  16. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +36 -0
  17. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.mm +102 -0
  18. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.mm +17 -0
  19. package/{src/AdsConsentPrivacyOptionsRequirementStatus.ts → ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.h} +21 -20
  20. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.mm +102 -0
  21. package/{lib/module/AdsConsentStatus.js → ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h} +20 -12
  22. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.mm +100 -0
  23. package/ios/RNGoogleMobileAds/common/{RNAppModule.m → RNAppModule.mm} +0 -76
  24. package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +0 -4
  25. package/ios/RNGoogleMobileAds/common/{RNSharedUtils.m → RNSharedUtils.mm} +0 -21
  26. package/jest.setup.ts +8 -5
  27. package/lib/commonjs/AdsConsent.js +16 -16
  28. package/lib/commonjs/AdsConsent.js.map +1 -1
  29. package/lib/commonjs/MobileAds.js +1 -1
  30. package/lib/commonjs/ads/AppOpenAd.js +3 -1
  31. package/lib/commonjs/ads/AppOpenAd.js.map +1 -1
  32. package/lib/commonjs/ads/BannerAd.js +1 -1
  33. package/lib/commonjs/ads/BannerAd.js.map +1 -1
  34. package/lib/commonjs/ads/BaseAd.js +1 -1
  35. package/lib/commonjs/ads/GAMBannerAd.js +1 -1
  36. package/lib/commonjs/ads/GAMBannerAd.js.map +1 -1
  37. package/lib/commonjs/ads/InterstitialAd.js +3 -1
  38. package/lib/commonjs/ads/InterstitialAd.js.map +1 -1
  39. package/lib/commonjs/ads/MobileAd.js +5 -18
  40. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  41. package/lib/commonjs/ads/RewardedAd.js +3 -1
  42. package/lib/commonjs/ads/RewardedAd.js.map +1 -1
  43. package/lib/commonjs/ads/RewardedInterstitialAd.js +3 -1
  44. package/lib/commonjs/ads/RewardedInterstitialAd.js.map +1 -1
  45. package/lib/commonjs/common/constants.js +4 -3
  46. package/lib/commonjs/common/constants.js.map +1 -1
  47. package/lib/commonjs/index.js +34 -8
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/specs/components/GoogleMobileAdsBannerViewNativeComponent.js.map +1 -0
  50. package/{src/AdsConsentDebugGeography.ts → lib/commonjs/specs/modules/NativeAppOpenModule.js} +10 -23
  51. package/lib/commonjs/specs/modules/NativeAppOpenModule.js.map +1 -0
  52. package/lib/commonjs/specs/modules/NativeConsentModule.js +67 -0
  53. package/lib/commonjs/specs/modules/NativeConsentModule.js.map +1 -0
  54. package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js +25 -0
  55. package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
  56. package/lib/commonjs/specs/modules/NativeInterstitialModule.js +25 -0
  57. package/lib/commonjs/specs/modules/NativeInterstitialModule.js.map +1 -0
  58. package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js +25 -0
  59. package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
  60. package/lib/commonjs/specs/modules/NativeRewardedModule.js +25 -0
  61. package/lib/commonjs/specs/modules/NativeRewardedModule.js.map +1 -0
  62. package/lib/commonjs/types/index.js +0 -11
  63. package/lib/commonjs/types/index.js.map +1 -1
  64. package/lib/commonjs/version.js +1 -1
  65. package/lib/module/AdsConsent.js +2 -3
  66. package/lib/module/AdsConsent.js.map +1 -1
  67. package/lib/module/MobileAds.js +1 -1
  68. package/lib/module/MobileAds.js.map +1 -1
  69. package/lib/module/ads/AppOpenAd.js +2 -1
  70. package/lib/module/ads/AppOpenAd.js.map +1 -1
  71. package/lib/module/ads/BannerAd.js +1 -1
  72. package/lib/module/ads/BannerAd.js.map +1 -1
  73. package/lib/module/ads/BaseAd.js +1 -1
  74. package/lib/module/ads/BaseAd.js.map +1 -1
  75. package/lib/module/ads/GAMBannerAd.js +1 -1
  76. package/lib/module/ads/GAMBannerAd.js.map +1 -1
  77. package/lib/module/ads/InterstitialAd.js +3 -1
  78. package/lib/module/ads/InterstitialAd.js.map +1 -1
  79. package/lib/module/ads/MobileAd.js +5 -18
  80. package/lib/module/ads/MobileAd.js.map +1 -1
  81. package/lib/module/ads/RewardedAd.js +3 -1
  82. package/lib/module/ads/RewardedAd.js.map +1 -1
  83. package/lib/module/ads/RewardedInterstitialAd.js +3 -1
  84. package/lib/module/ads/RewardedInterstitialAd.js.map +1 -1
  85. package/lib/module/common/constants.js +3 -3
  86. package/lib/module/common/constants.js.map +1 -1
  87. package/lib/module/index.js +1 -3
  88. package/lib/module/index.js.map +1 -1
  89. package/lib/module/specs/components/GoogleMobileAdsBannerViewNativeComponent.js.map +1 -0
  90. package/{ios/RNGoogleMobileAds/common/RNMeta.h → lib/module/specs/modules/NativeAppOpenModule.js} +3 -13
  91. package/lib/module/specs/modules/NativeAppOpenModule.js.map +1 -0
  92. package/lib/module/specs/modules/NativeConsentModule.js +68 -0
  93. package/lib/module/specs/modules/NativeConsentModule.js.map +1 -0
  94. package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js +20 -0
  95. package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
  96. package/lib/module/specs/modules/NativeInterstitialModule.js +20 -0
  97. package/lib/module/specs/modules/NativeInterstitialModule.js.map +1 -0
  98. package/lib/module/specs/modules/NativeRewardedInterstitialModule.js +20 -0
  99. package/lib/module/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
  100. package/lib/module/specs/modules/NativeRewardedModule.js +20 -0
  101. package/lib/module/specs/modules/NativeRewardedModule.js.map +1 -0
  102. package/lib/module/types/index.js +0 -1
  103. package/lib/module/types/index.js.map +1 -1
  104. package/lib/module/version.js +1 -1
  105. package/lib/typescript/AdsConsent.d.ts +1 -1
  106. package/lib/typescript/AdsConsent.d.ts.map +1 -1
  107. package/lib/typescript/ads/AppOpenAd.d.ts.map +1 -1
  108. package/lib/typescript/ads/BannerAd.d.ts.map +1 -1
  109. package/lib/typescript/ads/BaseAd.d.ts +1 -1
  110. package/lib/typescript/ads/BaseAd.d.ts.map +1 -1
  111. package/lib/typescript/ads/GAMBannerAd.d.ts.map +1 -1
  112. package/lib/typescript/ads/InterstitialAd.d.ts.map +1 -1
  113. package/lib/typescript/ads/MobileAd.d.ts +5 -4
  114. package/lib/typescript/ads/MobileAd.d.ts.map +1 -1
  115. package/lib/typescript/ads/RewardedAd.d.ts.map +1 -1
  116. package/lib/typescript/ads/RewardedInterstitialAd.d.ts.map +1 -1
  117. package/lib/typescript/index.d.ts +2 -4
  118. package/lib/typescript/index.d.ts.map +1 -1
  119. package/lib/typescript/specs/components/GoogleMobileAdsBannerViewNativeComponent.d.ts.map +1 -0
  120. package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts +25 -0
  121. package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts.map +1 -0
  122. package/lib/typescript/{types/AdsConsent.interface.d.ts → specs/modules/NativeConsentModule.d.ts} +249 -172
  123. package/lib/typescript/specs/modules/NativeConsentModule.d.ts.map +1 -0
  124. package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts +36 -0
  125. package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts.map +1 -0
  126. package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts +25 -0
  127. package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts.map +1 -0
  128. package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts +25 -0
  129. package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts.map +1 -0
  130. package/lib/typescript/specs/modules/NativeRewardedModule.d.ts +25 -0
  131. package/lib/typescript/specs/modules/NativeRewardedModule.d.ts.map +1 -0
  132. package/lib/typescript/types/index.d.ts +0 -1
  133. package/lib/typescript/types/index.d.ts.map +1 -1
  134. package/lib/typescript/version.d.ts +1 -1
  135. package/package.json +2 -2
  136. package/src/AdsConsent.ts +17 -21
  137. package/src/MobileAds.ts +1 -1
  138. package/src/ads/AppOpenAd.ts +3 -1
  139. package/src/ads/BannerAd.tsx +3 -1
  140. package/src/ads/BaseAd.tsx +2 -2
  141. package/src/ads/GAMBannerAd.tsx +3 -1
  142. package/src/ads/InterstitialAd.ts +3 -1
  143. package/src/ads/MobileAd.ts +9 -25
  144. package/src/ads/RewardedAd.ts +3 -1
  145. package/src/ads/RewardedInterstitialAd.ts +3 -1
  146. package/src/common/constants.ts +2 -2
  147. package/src/index.ts +9 -3
  148. package/src/specs/modules/NativeAppOpenModule.ts +26 -0
  149. package/src/{types/AdsConsent.interface.ts → specs/modules/NativeConsentModule.ts} +262 -174
  150. package/src/specs/modules/NativeGoogleMobileAdsModule.ts +40 -0
  151. package/src/specs/modules/NativeInterstitialModule.ts +26 -0
  152. package/src/specs/modules/NativeRewardedInterstitialModule.ts +32 -0
  153. package/src/{AdsConsentStatus.ts → specs/modules/NativeRewardedModule.ts} +8 -23
  154. package/src/types/index.ts +0 -1
  155. package/src/version.ts +1 -1
  156. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +0 -46
  157. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.swift +0 -85
  158. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.swift +0 -231
  159. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.swift +0 -76
  160. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +0 -46
  161. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.swift +0 -123
  162. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.m +0 -46
  163. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.swift +0 -85
  164. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +0 -46
  165. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.swift +0 -85
  166. package/ios/RNGoogleMobileAds/common/RNJSON.m +0 -93
  167. package/ios/RNGoogleMobileAds/common/RNMeta.m +0 -61
  168. package/ios/RNGoogleMobileAds/common/RNPreferences.h +0 -44
  169. package/ios/RNGoogleMobileAds/common/RNPreferences.m +0 -94
  170. package/lib/commonjs/AdsConsentDebugGeography.js +0 -34
  171. package/lib/commonjs/AdsConsentDebugGeography.js.map +0 -1
  172. package/lib/commonjs/AdsConsentPrivacyOptionsRequirementStatus.js +0 -32
  173. package/lib/commonjs/AdsConsentPrivacyOptionsRequirementStatus.js.map +0 -1
  174. package/lib/commonjs/AdsConsentStatus.js +0 -33
  175. package/lib/commonjs/AdsConsentStatus.js.map +0 -1
  176. package/lib/commonjs/NativeGoogleMobileAdsModule.js +0 -9
  177. package/lib/commonjs/NativeGoogleMobileAdsModule.js.map +0 -1
  178. package/lib/commonjs/ads/GoogleMobileAdsBannerViewNativeComponent.js.map +0 -1
  179. package/lib/commonjs/types/AdsConsent.interface.js +0 -6
  180. package/lib/commonjs/types/AdsConsent.interface.js.map +0 -1
  181. package/lib/module/AdsConsentDebugGeography.js +0 -29
  182. package/lib/module/AdsConsentDebugGeography.js.map +0 -1
  183. package/lib/module/AdsConsentPrivacyOptionsRequirementStatus.js +0 -27
  184. package/lib/module/AdsConsentPrivacyOptionsRequirementStatus.js.map +0 -1
  185. package/lib/module/AdsConsentStatus.js.map +0 -1
  186. package/lib/module/NativeGoogleMobileAdsModule.js +0 -3
  187. package/lib/module/NativeGoogleMobileAdsModule.js.map +0 -1
  188. package/lib/module/ads/GoogleMobileAdsBannerViewNativeComponent.js.map +0 -1
  189. package/lib/module/types/AdsConsent.interface.js +0 -2
  190. package/lib/module/types/AdsConsent.interface.js.map +0 -1
  191. package/lib/typescript/AdsConsentDebugGeography.d.ts +0 -20
  192. package/lib/typescript/AdsConsentDebugGeography.d.ts.map +0 -1
  193. package/lib/typescript/AdsConsentPrivacyOptionsRequirementStatus.d.ts +0 -18
  194. package/lib/typescript/AdsConsentPrivacyOptionsRequirementStatus.d.ts.map +0 -1
  195. package/lib/typescript/AdsConsentStatus.d.ts +0 -22
  196. package/lib/typescript/AdsConsentStatus.d.ts.map +0 -1
  197. package/lib/typescript/NativeGoogleMobileAdsModule.d.ts +0 -14
  198. package/lib/typescript/NativeGoogleMobileAdsModule.d.ts.map +0 -1
  199. package/lib/typescript/ads/GoogleMobileAdsBannerViewNativeComponent.d.ts.map +0 -1
  200. package/lib/typescript/types/AdsConsent.interface.d.ts.map +0 -1
  201. package/src/NativeGoogleMobileAdsModule.ts +0 -16
  202. /package/ios/RNGoogleMobileAds/common/{RNRCTEventEmitter.m → RNRCTEventEmitter.mm} +0 -0
  203. /package/lib/commonjs/{ads → specs/components}/GoogleMobileAdsBannerViewNativeComponent.js +0 -0
  204. /package/lib/module/{ads → specs/components}/GoogleMobileAdsBannerViewNativeComponent.js +0 -0
  205. /package/lib/typescript/{ads → specs/components}/GoogleMobileAdsBannerViewNativeComponent.d.ts +0 -0
  206. /package/src/{ads → specs/components}/GoogleMobileAdsBannerViewNativeComponent.ts +0 -0
@@ -1,85 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !targetEnvironment(macCatalyst)
19
-
20
- import Foundation
21
- import GoogleMobileAds
22
-
23
- @objc(RNGoogleMobileAdsAppOpenModule)
24
- class RNGoogleMobileAdsAppOpenModule: NSObject {
25
- let ad = RNGoogleMobileAdsAppOpenAd()
26
-
27
- deinit {
28
- invalidate()
29
- }
30
-
31
- @objc
32
- func invalidate() {
33
- ad.invalidate()
34
- }
35
-
36
- @objc(appOpenLoad:forAdUnitId:withAdRequestOptions:)
37
- func appOpenLoad(
38
- requestId: NSNumber,
39
- adUnitId: String,
40
- adRequestOptions: Dictionary<String, Any>
41
- ) {
42
- ad.load(
43
- requestId: requestId.intValue,
44
- adUnitId: adUnitId,
45
- adRequestOptions: adRequestOptions
46
- )
47
- }
48
-
49
- @objc(appOpenShow:forAdUnitId:withShowOptions:withResolve:withReject:)
50
- func appOpenShow(
51
- requestId: NSNumber,
52
- adUnitId: String,
53
- showOptions: Dictionary<String, Any>,
54
- resolve: RCTPromiseResolveBlock?,
55
- reject: RCTPromiseRejectBlock?
56
- ) {
57
- ad.show(
58
- requestId: requestId.intValue,
59
- adUnitId: adUnitId,
60
- showOptions: showOptions,
61
- resolve: resolve,
62
- reject: reject
63
- )
64
- }
65
-
66
- class RNGoogleMobileAdsAppOpenAd: RNGoogleMobileAdsFullScreenAd<GADAppOpenAd> {
67
- override func getAdEventName() -> String {
68
- return GOOGLE_MOBILE_ADS_EVENT_APP_OPEN
69
- }
70
-
71
- override func loadAd(
72
- adUnitId: String,
73
- adRequest: GAMRequest,
74
- completionHandler: @escaping (GADAppOpenAd?, Error?) -> ()
75
- ) {
76
- GADAppOpenAd.load(
77
- withAdUnitID: adUnitId,
78
- request: adRequest,
79
- completionHandler: completionHandler
80
- )
81
- }
82
- }
83
- }
84
-
85
- #endif
@@ -1,231 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !targetEnvironment(macCatalyst)
19
-
20
- import Foundation
21
- import GoogleMobileAds
22
-
23
- class RNGoogleMobileAdsFullScreenAd<T>: NSObject where T : GADFullScreenPresentingAd {
24
- var adMap = Dictionary<Int, T>()
25
- var delegateMap = Dictionary<Int, RNGoogleMobileAdsFullScreenContentDelegate>()
26
-
27
- deinit {
28
- invalidate()
29
- }
30
-
31
- func invalidate() {
32
- adMap.removeAll()
33
- delegateMap.removeAll()
34
- }
35
-
36
- func getAdEventName() -> String {
37
- fatalError("Method `getAdEventName` must be overriden")
38
- }
39
-
40
- func loadAd(
41
- adUnitId: String,
42
- adRequest: GAMRequest,
43
- completionHandler: @escaping (_ ad: T?, _ error: Error?) -> ()
44
- ) {
45
- fatalError("Method `loadAd` must be overriden")
46
- }
47
-
48
- func sendAdEvent(
49
- _ type: String,
50
- requestId: Int,
51
- adUnitId: String,
52
- error: Dictionary<String, Any>?,
53
- data: Dictionary<String, Any>?
54
- ) {
55
- RNGoogleMobileAdsCommon.sendAdEvent(
56
- getAdEventName(),
57
- requestId: requestId as NSNumber,
58
- type: type,
59
- adUnitId: adUnitId,
60
- error: error,
61
- data: data
62
- )
63
- }
64
-
65
- //MARK: - Load function
66
-
67
- func load(
68
- requestId: Int,
69
- adUnitId: String,
70
- adRequestOptions: Dictionary<String, Any>
71
- ) {
72
- let adRequest = RNGoogleMobileAdsCommon.buildAdRequest(adRequestOptions)!
73
-
74
- let delegate = RNGoogleMobileAdsFullScreenContentDelegate(
75
- adEventName: getAdEventName(),
76
- requestId: requestId,
77
- adUnitId: adUnitId
78
- )
79
-
80
- let completionHandler = { (ad: T?, error: Error?) -> () in
81
- var eventType = GOOGLE_MOBILE_ADS_EVENT_LOADED
82
- var data: Dictionary<String, Any>? = nil
83
- if let error = error {
84
- let codeAndMessage = RNGoogleMobileAdsCommon.getCodeAndMessage(fromAdError: error)
85
- self.sendAdEvent(
86
- GOOGLE_MOBILE_ADS_EVENT_ERROR,
87
- requestId: requestId,
88
- adUnitId: adUnitId,
89
- error: codeAndMessage as? Dictionary<String, Any>,
90
- data: nil
91
- )
92
- return
93
- }
94
-
95
- let paidEventHandler = {(value: GADAdValue) in
96
- self.sendAdEvent(
97
- "paid",
98
- requestId: requestId,
99
- adUnitId: adUnitId,
100
- error: nil,
101
- data: [
102
- "value": value.value,
103
- "precision": value.precision.rawValue,
104
- "currency": value.currencyCode,
105
- ]
106
- );
107
- };
108
-
109
- (ad as? GADRewardedAd)?.paidEventHandler = paidEventHandler;
110
- (ad as? GADRewardedInterstitialAd)?.paidEventHandler = paidEventHandler;
111
- (ad as? GADInterstitialAd)?.paidEventHandler = paidEventHandler;
112
- (ad as? GADAppOpenAd)?.paidEventHandler = paidEventHandler;
113
-
114
- if (ad is GADRewardedAd || ad is GADRewardedInterstitialAd) {
115
- if let serverSideVerificationOptions =
116
- adRequestOptions["serverSideVerificationOptions"] as? Dictionary<String, Any> {
117
- let options = GADServerSideVerificationOptions()
118
-
119
- if let userId = serverSideVerificationOptions["userId"] as? String {
120
- options.userIdentifier = userId
121
- }
122
- if let customData = serverSideVerificationOptions["customData"] as? String {
123
- options.customRewardString = customData
124
- }
125
-
126
- if let ad = ad as? GADRewardedAd {
127
- ad.serverSideVerificationOptions = options
128
- }
129
- else if let ad = ad as? GADRewardedInterstitialAd {
130
- ad.serverSideVerificationOptions = options
131
- }
132
- }
133
-
134
- eventType = GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED
135
-
136
- let adReward = (ad as? GADRewardedAd)?.adReward ?? (ad as? GADRewardedInterstitialAd)?.adReward
137
- data = [
138
- "type": adReward!.type,
139
- "amount": adReward!.amount
140
- ]
141
- }
142
-
143
- if let ad = ad as? GAMInterstitialAd {
144
- ad.appEventDelegate = delegate
145
- }
146
-
147
- ad!.fullScreenContentDelegate = delegate
148
-
149
- self.adMap.updateValue(ad!, forKey: requestId)
150
- self.delegateMap.updateValue(delegate, forKey: requestId)
151
- self.sendAdEvent(
152
- eventType,
153
- requestId: requestId,
154
- adUnitId: adUnitId,
155
- error: nil,
156
- data: data
157
- )
158
- }
159
-
160
- loadAd(adUnitId: adUnitId, adRequest: adRequest, completionHandler: completionHandler)
161
- }
162
-
163
- //MARK: - Show function
164
-
165
- func show(
166
- requestId: Int,
167
- adUnitId: String,
168
- showOptions: Dictionary<String, Any>,
169
- resolve: RCTPromiseResolveBlock?,
170
- reject: RCTPromiseRejectBlock?
171
- ) {
172
- guard let viewController = RNGoogleMobileAdsCommon.currentViewController() else {
173
- RNSharedUtils.rejectPromise(userInfo: reject, userInfo: [
174
- "code" : "nil-vc",
175
- "message" : "Ad attempted to show but the current View Controller was nil.",
176
- ])
177
- return
178
- }
179
-
180
- guard let ad = adMap[requestId] else {
181
- RNSharedUtils.rejectPromise(userInfo: reject, userInfo: [
182
- "code" : "not-ready",
183
- "message" : "Ad attempted to show but was not ready.",
184
- ])
185
- return
186
- }
187
-
188
- var rewardData: Dictionary<String, Any>? = nil
189
- if let adReward =
190
- (ad as? GADRewardedAd)?.adReward ??
191
- (ad as? GADRewardedInterstitialAd)?.adReward {
192
- rewardData = [
193
- "type": adReward.type,
194
- "amount": adReward.amount
195
- ]
196
- }
197
- let userDidEarnRewardHandler = { () -> Void in
198
- self.sendAdEvent(
199
- GOOGLE_MOBILE_ADS_EVENT_REWARDED_EARNED_REWARD,
200
- requestId: requestId,
201
- adUnitId: adUnitId,
202
- error: nil,
203
- data: rewardData
204
- )
205
- }
206
-
207
- // TODO: Find way to compact this area
208
- if let ad = ad as? GADAppOpenAd {
209
- ad.present(fromRootViewController: viewController)
210
- }
211
- else if let ad = ad as? GADInterstitialAd {
212
- ad.present(fromRootViewController: viewController)
213
- }
214
- else if let ad = ad as? GADRewardedAd {
215
- ad.present(
216
- fromRootViewController: viewController,
217
- userDidEarnRewardHandler: userDidEarnRewardHandler
218
- )
219
- }
220
- else if let ad = ad as? GADRewardedInterstitialAd {
221
- ad.present(
222
- fromRootViewController: viewController,
223
- userDidEarnRewardHandler: userDidEarnRewardHandler
224
- )
225
- }
226
-
227
- resolve!(nil)
228
- }
229
- }
230
-
231
- #endif
@@ -1,76 +0,0 @@
1
- #if !targetEnvironment(macCatalyst)
2
-
3
- import Foundation
4
- import GoogleMobileAds
5
-
6
- class RNGoogleMobileAdsFullScreenContentDelegate: NSObject, GADFullScreenContentDelegate, GADAppEventDelegate {
7
- let adEventName: String
8
- let requestId: Int
9
- let adUnitId: String
10
-
11
- init(adEventName: String, requestId: Int, adUnitId: String) {
12
- self.adEventName = adEventName
13
- self.requestId = requestId
14
- self.adUnitId = adUnitId
15
- }
16
-
17
- func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
18
- sendAdEvent(
19
- type: GOOGLE_MOBILE_ADS_EVENT_OPENED,
20
- error: nil,
21
- data: nil
22
- )
23
- }
24
-
25
- func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
26
- sendAdEvent(
27
- type: GOOGLE_MOBILE_ADS_EVENT_ERROR,
28
- error: RNGoogleMobileAdsCommon.getCodeAndMessage(fromAdError: error) as? Dictionary<String, Any>,
29
- data: nil
30
- )
31
- }
32
-
33
- func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
34
- sendAdEvent(
35
- type: GOOGLE_MOBILE_ADS_EVENT_CLOSED,
36
- error: nil,
37
- data: nil
38
- )
39
- }
40
-
41
- func adDidRecordClick(_ ad: GADFullScreenPresentingAd) {
42
- sendAdEvent(
43
- type: GOOGLE_MOBILE_ADS_EVENT_CLICKED,
44
- error: nil,
45
- data: nil
46
- )
47
- }
48
-
49
- func adDidRecordImpression(_ ad: GADFullScreenPresentingAd) {
50
- // Not implemented yet
51
- }
52
-
53
- func interstitialAd(_ interstitialAd: GADInterstitialAd, didReceiveAppEvent name: String, withInfo info: String?) {
54
- sendAdEvent(
55
- type: GOOGLE_MOBILE_ADS_EVENT_APP_EVENT,
56
- error: nil,
57
- data: [
58
- "name": name,
59
- "data": info ?? ""
60
- ]
61
- )
62
- }
63
-
64
- private func sendAdEvent(type: String, error: Dictionary<String, Any>?, data: Dictionary<String, Any>?) {
65
- RNGoogleMobileAdsCommon.sendAdEvent(
66
- adEventName,
67
- requestId: requestId as NSNumber,
68
- type: type,
69
- adUnitId: adUnitId,
70
- error: error,
71
- data: data
72
- )
73
- }
74
- }
75
-
76
- #endif
@@ -1,46 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !TARGET_OS_MACCATALYST
19
-
20
- #import <React/RCTBridgeModule.h>
21
-
22
- @interface RCT_EXTERN_MODULE (RNGoogleMobileAdsInterstitialModule, NSObject)
23
-
24
- - (dispatch_queue_t)methodQueue {
25
- return dispatch_get_main_queue();
26
- }
27
-
28
- + (BOOL)requiresMainQueueSetup {
29
- return YES;
30
- }
31
-
32
- RCT_EXTERN_METHOD(interstitialLoad
33
- : (nonnull NSNumber *)requestId forAdUnitId
34
- : (nonnull NSString *)adUnitId withAdRequestOptions
35
- : (nonnull NSDictionary *)adRequestOptions)
36
-
37
- RCT_EXTERN_METHOD(interstitialShow
38
- : (nonnull NSNumber *)requestId forAdUnitId
39
- : (nonnull NSString *)adUnitId withShowOptions
40
- : (NSDictionary *)showOptions withResolve
41
- : (RCTPromiseResolveBlock)resolve withReject
42
- : (RCTPromiseRejectBlock)reject)
43
-
44
- @end
45
-
46
- #endif
@@ -1,123 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !targetEnvironment(macCatalyst)
19
-
20
- import Foundation
21
- import GoogleMobileAds
22
-
23
- @objc(RNGoogleMobileAdsInterstitialModule)
24
- class RNGoogleMobileAdsInterstitialModule: NSObject {
25
- let ad = RNGoogleMobileAdsInterstitialAd()
26
- let gamAd = RNGoogleMobileAdsGAMInterstitialAd()
27
-
28
- deinit {
29
- invalidate()
30
- }
31
-
32
- @objc
33
- func invalidate() {
34
- ad.invalidate()
35
- gamAd.invalidate()
36
- }
37
-
38
- @objc(interstitialLoad:forAdUnitId:withAdRequestOptions:)
39
- func interstitialLoad(
40
- requestId: NSNumber,
41
- adUnitId: String,
42
- adRequestOptions: Dictionary<String, Any>
43
- ) {
44
- if (RNGoogleMobileAdsCommon.isAdManagerUnit(adUnitId)) {
45
- gamAd.load(
46
- requestId: requestId.intValue,
47
- adUnitId: adUnitId,
48
- adRequestOptions: adRequestOptions
49
- )
50
- } else {
51
- ad.load(
52
- requestId: requestId.intValue,
53
- adUnitId: adUnitId,
54
- adRequestOptions: adRequestOptions
55
- )
56
- }
57
- }
58
-
59
- @objc(interstitialShow:forAdUnitId:withShowOptions:withResolve:withReject:)
60
- func interstitialShow(
61
- requestId: NSNumber,
62
- adUnitId: String,
63
- showOptions: Dictionary<String, Any>,
64
- resolve: RCTPromiseResolveBlock?,
65
- reject: RCTPromiseRejectBlock?
66
- ) {
67
- if (RNGoogleMobileAdsCommon.isAdManagerUnit(adUnitId)) {
68
- gamAd.show(
69
- requestId: requestId.intValue,
70
- adUnitId: adUnitId,
71
- showOptions: showOptions,
72
- resolve: resolve,
73
- reject: reject
74
- )
75
- } else {
76
- ad.show(
77
- requestId: requestId.intValue,
78
- adUnitId: adUnitId,
79
- showOptions: showOptions,
80
- resolve: resolve,
81
- reject: reject
82
- )
83
- }
84
- }
85
-
86
- class RNGoogleMobileAdsInterstitialAd: RNGoogleMobileAdsFullScreenAd<GADInterstitialAd> {
87
- override func getAdEventName() -> String {
88
- return GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL
89
- }
90
-
91
- override func loadAd(
92
- adUnitId: String,
93
- adRequest: GAMRequest,
94
- completionHandler: @escaping (GADInterstitialAd?, Error?) -> ()
95
- ) {
96
- GADInterstitialAd.load(
97
- withAdUnitID: adUnitId,
98
- request: adRequest,
99
- completionHandler: completionHandler
100
- )
101
- }
102
- }
103
-
104
- class RNGoogleMobileAdsGAMInterstitialAd: RNGoogleMobileAdsFullScreenAd<GAMInterstitialAd> {
105
- override func getAdEventName() -> String {
106
- return GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL
107
- }
108
-
109
- override func loadAd(
110
- adUnitId: String,
111
- adRequest: GAMRequest,
112
- completionHandler: @escaping (GAMInterstitialAd?, Error?) -> ()
113
- ) {
114
- GAMInterstitialAd.load(
115
- withAdManagerAdUnitID: adUnitId,
116
- request: adRequest,
117
- completionHandler: completionHandler
118
- )
119
- }
120
- }
121
- }
122
-
123
- #endif
@@ -1,46 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !TARGET_OS_MACCATALYST
19
-
20
- #import <React/RCTBridgeModule.h>
21
-
22
- @interface RCT_EXTERN_MODULE (RNGoogleMobileAdsRewardedInterstitialModule, NSObject)
23
-
24
- - (dispatch_queue_t)methodQueue {
25
- return dispatch_get_main_queue();
26
- }
27
-
28
- + (BOOL)requiresMainQueueSetup {
29
- return YES;
30
- }
31
-
32
- RCT_EXTERN_METHOD(rewardedInterstitialLoad
33
- : (nonnull NSNumber *)requestId forAdUnitId
34
- : (nonnull NSString *)adUnitId withAdRequestOptions
35
- : (nonnull NSDictionary *)adRequestOptions)
36
-
37
- RCT_EXTERN_METHOD(rewardedInterstitialShow
38
- : (nonnull NSNumber *)requestId forAdUnitId
39
- : (nonnull NSString *)adUnitId withShowOptions
40
- : (NSDictionary *)showOptions withResolve
41
- : (RCTPromiseResolveBlock)resolve withReject
42
- : (RCTPromiseRejectBlock)reject)
43
-
44
- @end
45
-
46
- #endif
@@ -1,85 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- #if !targetEnvironment(macCatalyst)
19
-
20
- import Foundation
21
- import GoogleMobileAds
22
-
23
- @objc(RNGoogleMobileAdsRewardedInterstitialModule)
24
- class RNGoogleMobileAdsRewardedInterstitialModule: NSObject {
25
- let ad = RNGoogleMobileAdsRewardedInterstitialAd()
26
-
27
- deinit {
28
- invalidate()
29
- }
30
-
31
- @objc
32
- func invalidate() {
33
- ad.invalidate()
34
- }
35
-
36
- @objc(rewardedInterstitialLoad:forAdUnitId:withAdRequestOptions:)
37
- func rewardedInterstitialLoad(
38
- requestId: NSNumber,
39
- adUnitId: String,
40
- adRequestOptions: Dictionary<String, Any>
41
- ) {
42
- ad.load(
43
- requestId: requestId.intValue,
44
- adUnitId: adUnitId,
45
- adRequestOptions: adRequestOptions
46
- )
47
- }
48
-
49
- @objc(rewardedInterstitialShow:forAdUnitId:withShowOptions:withResolve:withReject:)
50
- func rewardedInterstitialShow(
51
- requestId: NSNumber,
52
- adUnitId: String,
53
- showOptions: Dictionary<String, Any>,
54
- resolve: RCTPromiseResolveBlock?,
55
- reject: RCTPromiseRejectBlock?
56
- ) {
57
- ad.show(
58
- requestId: requestId.intValue,
59
- adUnitId: adUnitId,
60
- showOptions: showOptions,
61
- resolve: resolve,
62
- reject: reject
63
- )
64
- }
65
-
66
- class RNGoogleMobileAdsRewardedInterstitialAd: RNGoogleMobileAdsFullScreenAd<GADRewardedInterstitialAd> {
67
- override func getAdEventName() -> String {
68
- return GOOGLE_MOBILE_ADS_EVENT_REWARDED_INTERSTITIAL
69
- }
70
-
71
- override func loadAd(
72
- adUnitId: String,
73
- adRequest: GAMRequest,
74
- completionHandler: @escaping (GADRewardedInterstitialAd?, Error?) -> ()
75
- ) {
76
- GADRewardedInterstitialAd.load(
77
- withAdUnitID: adUnitId,
78
- request: adRequest,
79
- completionHandler: completionHandler
80
- )
81
- }
82
- }
83
- }
84
-
85
- #endif