react-native-google-mobile-ads 16.3.2 → 16.3.4
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.
- package/README.md +1 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.mm +8 -14
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeAdRegistry.h +31 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeAdRegistry.mm +60 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.mm +13 -3
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.mm +5 -11
- package/lib/commonjs/version.js +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ When using The New Architecture, some legacy code will still be used though. See
|
|
|
145
145
|
- [Issues](https://github.com/invertase/react-native-google-mobile-ads/issues)
|
|
146
146
|
- [PRs](https://github.com/invertase/react-native-google-mobile-ads/pulls)
|
|
147
147
|
- [Guidelines](https://github.com/invertase/react-native-google-mobile-ads/blob/main/CONTRIBUTING.md)
|
|
148
|
-
- [Code of Conduct](https://github.com/invertase/
|
|
148
|
+
- [Code of Conduct](https://github.com/invertase/.github/blob/main/CODE_OF_CONDUCT.md)
|
|
149
149
|
|
|
150
150
|
## License
|
|
151
151
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
#import "RNGoogleMobileAdsMediaView.h"
|
|
19
|
-
#import "
|
|
19
|
+
#import "RNGoogleMobileAdsNativeAdRegistry.h"
|
|
20
20
|
|
|
21
21
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
22
22
|
#import <react/renderer/components/RNGoogleMobileAdsSpec/ComponentDescriptors.h>
|
|
@@ -27,10 +27,6 @@
|
|
|
27
27
|
#import "RCTFabricComponentsPlugins.h"
|
|
28
28
|
#endif
|
|
29
29
|
|
|
30
|
-
@interface RCTBridge (Private)
|
|
31
|
-
+ (RCTBridge *)currentBridge;
|
|
32
|
-
@end
|
|
33
|
-
|
|
34
30
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
35
31
|
using namespace facebook::react;
|
|
36
32
|
|
|
@@ -39,8 +35,6 @@ using namespace facebook::react;
|
|
|
39
35
|
#endif
|
|
40
36
|
|
|
41
37
|
@implementation RNGoogleMobileAdsMediaView {
|
|
42
|
-
__weak RCTBridge *_bridge;
|
|
43
|
-
__weak RNGoogleMobileAdsNativeModule *_nativeModule;
|
|
44
38
|
GADMediaView *_mediaView;
|
|
45
39
|
UIViewContentMode _contentMode;
|
|
46
40
|
}
|
|
@@ -52,11 +46,9 @@ using namespace facebook::react;
|
|
|
52
46
|
|
|
53
47
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
54
48
|
if (self = [super initWithFrame:frame]) {
|
|
55
|
-
static const auto defaultProps = std::make_shared<const
|
|
49
|
+
static const auto defaultProps = std::make_shared<const RNGoogleMobileAdsMediaViewProps>();
|
|
56
50
|
_props = defaultProps;
|
|
57
51
|
|
|
58
|
-
_bridge = [RCTBridge currentBridge];
|
|
59
|
-
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
60
52
|
_mediaView = [[GADMediaView alloc] init];
|
|
61
53
|
_contentMode = UIViewContentModeScaleAspectFill;
|
|
62
54
|
self.contentView = _mediaView;
|
|
@@ -99,9 +91,8 @@ using namespace facebook::react;
|
|
|
99
91
|
|
|
100
92
|
- (instancetype)initWithBridge:(RCTBridge *)bridge {
|
|
101
93
|
if (self = [super init]) {
|
|
102
|
-
_bridge = bridge;
|
|
103
|
-
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
104
94
|
_mediaView = self;
|
|
95
|
+
_contentMode = UIViewContentModeScaleAspectFill;
|
|
105
96
|
}
|
|
106
97
|
return self;
|
|
107
98
|
}
|
|
@@ -111,8 +102,11 @@ using namespace facebook::react;
|
|
|
111
102
|
#pragma mark - Common logics
|
|
112
103
|
|
|
113
104
|
- (void)setResponseId:(NSString *)responseId {
|
|
114
|
-
_responseId = responseId;
|
|
115
|
-
GADNativeAd *nativeAd = [
|
|
105
|
+
_responseId = [responseId copy];
|
|
106
|
+
GADNativeAd *nativeAd = [RNGoogleMobileAdsNativeAdRegistry nativeAdForResponseId:responseId];
|
|
107
|
+
if (nativeAd == nil) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
116
110
|
_mediaView.mediaContent = nativeAd.mediaContent;
|
|
117
111
|
_mediaView.contentMode = _contentMode;
|
|
118
112
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
#import <Foundation/Foundation.h>
|
|
19
|
+
#import <GoogleMobileAds/GADNativeAd.h>
|
|
20
|
+
|
|
21
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
22
|
+
|
|
23
|
+
@interface RNGoogleMobileAdsNativeAdRegistry : NSObject
|
|
24
|
+
|
|
25
|
+
+ (void)setNativeAd:(GADNativeAd *)nativeAd forResponseId:(NSString *)responseId;
|
|
26
|
+
+ (nullable GADNativeAd *)nativeAdForResponseId:(NSString *)responseId;
|
|
27
|
+
+ (void)removeNativeAdForResponseId:(NSString *)responseId;
|
|
28
|
+
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
#import "RNGoogleMobileAdsNativeAdRegistry.h"
|
|
19
|
+
|
|
20
|
+
@implementation RNGoogleMobileAdsNativeAdRegistry
|
|
21
|
+
|
|
22
|
+
static NSMapTable<NSString *, GADNativeAd *> *_nativeAds;
|
|
23
|
+
|
|
24
|
+
+ (void)initialize {
|
|
25
|
+
if (self == [RNGoogleMobileAdsNativeAdRegistry class]) {
|
|
26
|
+
_nativeAds = [NSMapTable strongToStrongObjectsMapTable];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (void)setNativeAd:(GADNativeAd *)nativeAd forResponseId:(NSString *)responseId {
|
|
31
|
+
if (responseId.length == 0 || nativeAd == nil) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@synchronized(self) {
|
|
36
|
+
[_nativeAds setObject:nativeAd forKey:responseId];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+ (nullable GADNativeAd *)nativeAdForResponseId:(NSString *)responseId {
|
|
41
|
+
if (responseId.length == 0) {
|
|
42
|
+
return nil;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@synchronized(self) {
|
|
46
|
+
return [_nativeAds objectForKey:responseId];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
+ (void)removeNativeAdForResponseId:(NSString *)responseId {
|
|
51
|
+
if (responseId.length == 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@synchronized(self) {
|
|
56
|
+
[_nativeAds removeObjectForKey:responseId];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@end
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
#import "RNGoogleMobileAdsNativeModule.h"
|
|
21
21
|
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
#import "RNGoogleMobileAdsNativeAdRegistry.h"
|
|
22
23
|
|
|
23
24
|
typedef void (^RNGMANativeAdLoadCompletionHandler)(GADNativeAd *_Nullable nativeAd,
|
|
24
25
|
NSError *_Nullable error);
|
|
@@ -48,6 +49,10 @@ RCT_EXPORT_MODULE();
|
|
|
48
49
|
return dispatch_get_main_queue();
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
53
|
+
return YES;
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
52
57
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
53
58
|
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
@@ -90,6 +95,7 @@ RCT_EXPORT_METHOD(
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
[_adHolders setValue:adHolder forKey:responseId];
|
|
98
|
+
[RNGoogleMobileAdsNativeAdRegistry setNativeAd:nativeAd forResponseId:responseId];
|
|
93
99
|
|
|
94
100
|
resolve(@{
|
|
95
101
|
@"responseId" : responseId,
|
|
@@ -114,14 +120,15 @@ RCT_EXPORT_METHOD(
|
|
|
114
120
|
|
|
115
121
|
RCT_EXPORT_METHOD(destroy
|
|
116
122
|
: (NSString *)responseId {
|
|
117
|
-
if (responseId) {
|
|
118
|
-
[[_adHolders
|
|
123
|
+
if (responseId.length > 0) {
|
|
124
|
+
[[_adHolders objectForKey:responseId] dispose];
|
|
119
125
|
[_adHolders removeObjectForKey:responseId];
|
|
126
|
+
[RNGoogleMobileAdsNativeAdRegistry removeNativeAdForResponseId:responseId];
|
|
120
127
|
}
|
|
121
128
|
});
|
|
122
129
|
|
|
123
130
|
- (GADNativeAd *)nativeAdForResponseId:(NSString *)responseId {
|
|
124
|
-
return [
|
|
131
|
+
return [RNGoogleMobileAdsNativeAdRegistry nativeAdForResponseId:responseId];
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
- (void)dealloc {
|
|
@@ -129,6 +136,9 @@ RCT_EXPORT_METHOD(destroy
|
|
|
129
136
|
for (RNGMANativeAdHolder *adHolder in adHolders) {
|
|
130
137
|
[adHolder dispose];
|
|
131
138
|
}
|
|
139
|
+
for (NSString *responseId in [_adHolders allKeys]) {
|
|
140
|
+
[RNGoogleMobileAdsNativeAdRegistry removeNativeAdForResponseId:responseId];
|
|
141
|
+
}
|
|
132
142
|
[_adHolders removeAllObjects];
|
|
133
143
|
}
|
|
134
144
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#import "RNGoogleMobileAdsNativeView.h"
|
|
19
19
|
#import "RNGoogleMobileAdsMediaView.h"
|
|
20
|
-
#import "
|
|
20
|
+
#import "RNGoogleMobileAdsNativeAdRegistry.h"
|
|
21
21
|
|
|
22
22
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
23
23
|
#import <react/renderer/components/RNGoogleMobileAdsSpec/ComponentDescriptors.h>
|
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
#import "RCTFabricComponentsPlugins.h"
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
-
@interface RCTBridge (Private)
|
|
32
|
-
+ (RCTBridge *)currentBridge;
|
|
33
|
-
@end
|
|
34
|
-
|
|
35
31
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
36
32
|
using namespace facebook::react;
|
|
37
33
|
|
|
@@ -40,8 +36,9 @@ using namespace facebook::react;
|
|
|
40
36
|
#endif
|
|
41
37
|
|
|
42
38
|
@implementation RNGoogleMobileAdsNativeView {
|
|
39
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
43
40
|
__weak RCTBridge *_bridge;
|
|
44
|
-
|
|
41
|
+
#endif
|
|
45
42
|
__weak GADNativeAd *_nativeAd;
|
|
46
43
|
GADNativeAdView *_nativeAdView;
|
|
47
44
|
dispatch_block_t _debouncedReload;
|
|
@@ -57,8 +54,6 @@ using namespace facebook::react;
|
|
|
57
54
|
static const auto defaultProps = std::make_shared<const RNGoogleMobileAdsNativeViewProps>();
|
|
58
55
|
_props = defaultProps;
|
|
59
56
|
|
|
60
|
-
_bridge = [RCTBridge currentBridge];
|
|
61
|
-
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
62
57
|
_nativeAdView = [[GADNativeAdView alloc] init];
|
|
63
58
|
self.contentView = _nativeAdView;
|
|
64
59
|
}
|
|
@@ -127,7 +122,6 @@ using namespace facebook::react;
|
|
|
127
122
|
- (instancetype)initWithBridge:(RCTBridge *)bridge {
|
|
128
123
|
if (self = [super init]) {
|
|
129
124
|
_bridge = bridge;
|
|
130
|
-
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
131
125
|
_nativeAdView = self;
|
|
132
126
|
}
|
|
133
127
|
return self;
|
|
@@ -138,8 +132,8 @@ using namespace facebook::react;
|
|
|
138
132
|
#pragma mark - Common logics
|
|
139
133
|
|
|
140
134
|
- (void)setResponseId:(NSString *)responseId {
|
|
141
|
-
_responseId = responseId;
|
|
142
|
-
_nativeAd = [
|
|
135
|
+
_responseId = [responseId copy];
|
|
136
|
+
_nativeAd = [RNGoogleMobileAdsNativeAdRegistry nativeAdForResponseId:responseId];
|
|
143
137
|
[self reloadAd];
|
|
144
138
|
}
|
|
145
139
|
|
package/lib/commonjs/version.js
CHANGED
package/lib/module/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "16.3.
|
|
1
|
+
export declare const SDK_VERSION = "16.3.4";
|
|
2
2
|
export { default, MobileAds } from './MobileAds';
|
|
3
3
|
export { AdsConsentDebugGeography, AdsConsentInfo, AdsConsentInfoOptions, AdsConsentInterface, AdsConsentPrivacyOptionsRequirementStatus, AdsConsentStatus, AdsConsentUserChoices, } from './specs/modules/NativeConsentModule';
|
|
4
4
|
export { AdsConsentPurposes } from './AdsConsentPurposes';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "16.3.
|
|
1
|
+
export declare const version = "16.3.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-google-mobile-ads",
|
|
3
|
-
"version": "16.3.
|
|
3
|
+
"version": "16.3.4",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '16.3.
|
|
2
|
+
export const version = '16.3.4';
|