react-native-google-mobile-ads 4.1.3 → 5.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.
- package/RNGoogleMobileAds.podspec +16 -9
- package/__tests__/consent.test.ts +17 -9
- package/android/build.gradle +4 -3
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +13 -2
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +100 -171
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +1 -1
- package/docs/european-user-consent.mdx +43 -161
- package/docs/index.mdx +12 -12
- package/docs/migrating-to-v5.mdx +54 -0
- package/docs.json +2 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +1 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +6 -2
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +0 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +71 -126
- package/ios_config.sh +8 -0
- package/lib/commonjs/AdsConsent.js +29 -100
- package/lib/commonjs/AdsConsent.js.map +1 -1
- package/lib/commonjs/AdsConsentStatus.js +4 -3
- package/lib/commonjs/AdsConsentStatus.js.map +1 -1
- package/lib/commonjs/validateAdRequestOptions.js +8 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/AdsConsent.js +30 -100
- package/lib/module/AdsConsent.js.map +1 -1
- package/lib/module/AdsConsentStatus.js +4 -3
- package/lib/module/AdsConsentStatus.js.map +1 -1
- package/lib/module/validateAdRequestOptions.js +8 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/AdsConsentStatus.d.ts +10 -6
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/types/AdsConsent.interface.d.ts +37 -204
- package/lib/typescript/types/RequestOptions.d.ts +8 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +5 -3
- package/src/AdsConsent.ts +36 -135
- package/src/AdsConsentStatus.ts +11 -6
- package/src/types/AdsConsent.interface.ts +37 -214
- package/src/types/RequestOptions.ts +7 -0
- package/src/validateAdRequestOptions.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
google_mobile_ads_sdk_version = package['sdkVersions']['ios']['googleMobileAds']
|
|
5
|
+
google_ump_sdk_version = package['sdkVersions']['ios']['googleUmp']
|
|
5
6
|
|
|
6
7
|
Pod::Spec.new do |s|
|
|
7
8
|
s.name = "RNGoogleMobileAds"
|
|
@@ -18,24 +19,30 @@ Pod::Spec.new do |s|
|
|
|
18
19
|
s.social_media_url = 'http://twitter.com/invertaseio'
|
|
19
20
|
s.ios.deployment_target = "10.0"
|
|
20
21
|
s.source_files = 'ios/**/*.{h,m}'
|
|
22
|
+
s.frameworks = "AppTrackingTransparency"
|
|
21
23
|
|
|
22
24
|
# React Native dependencies
|
|
23
25
|
s.dependency 'React-Core'
|
|
24
26
|
|
|
25
27
|
# Other dependencies
|
|
26
|
-
|
|
28
|
+
if defined?($RNGoogleUmpSDKVersion)
|
|
29
|
+
Pod::UI.puts "#{s.name}: Using user specified Google UMP SDK version '#{$RNGoogleUmpSDKVersion}'"
|
|
30
|
+
google_ump_sdk_version = $RNGoogleUmpSDKVersion
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
s.dependency 'GoogleUserMessagingPlatform', google_ump_sdk_version
|
|
27
34
|
|
|
28
|
-
if defined?($
|
|
29
|
-
Pod::UI.puts "#{s.name}: Using user specified Google Mobile-Ads SDK version '#{$
|
|
30
|
-
|
|
35
|
+
if defined?($RNGoogleMobileAdsSDKVersion)
|
|
36
|
+
Pod::UI.puts "#{s.name}: Using user specified Google Mobile-Ads SDK version '#{$RNGoogleMobileAdsSDKVersion}'"
|
|
37
|
+
google_mobile_ads_sdk_version = $RNGoogleMobileAdsSDKVersion
|
|
31
38
|
end
|
|
32
39
|
|
|
33
40
|
# AdMob dependencies
|
|
34
|
-
s.dependency 'Google-Mobile-Ads-SDK',
|
|
41
|
+
s.dependency 'Google-Mobile-Ads-SDK', google_mobile_ads_sdk_version
|
|
35
42
|
|
|
36
|
-
if defined?($
|
|
37
|
-
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$
|
|
38
|
-
s.static_framework = $
|
|
43
|
+
if defined?($RNGoogleMobileAdsAsStaticFramework)
|
|
44
|
+
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNGoogleMobileAdsAsStaticFramework}'"
|
|
45
|
+
s.static_framework = $RNGoogleMobileAdsAsStaticFramework
|
|
39
46
|
else
|
|
40
47
|
s.static_framework = false
|
|
41
48
|
end
|
|
@@ -2,23 +2,31 @@ import { AdsConsent } from '../src';
|
|
|
2
2
|
|
|
3
3
|
describe('Google Mobile Ads AdsConsent', function () {
|
|
4
4
|
describe('requestInfoUpdate', function () {
|
|
5
|
-
it('throws if
|
|
5
|
+
it('throws if options are not an object', function () {
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
expect(() => AdsConsent.requestInfoUpdate('
|
|
8
|
-
"AdsConsent.requestInfoUpdate(*) '
|
|
7
|
+
expect(() => AdsConsent.requestInfoUpdate('123')).toThrowError(
|
|
8
|
+
"AdsConsent.requestInfoUpdate(*) 'options' expected an object value.",
|
|
9
9
|
);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
it('throws if
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
it('throws if options.debugGeography is not a valid value.', function () {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
expect(() => AdsConsent.requestInfoUpdate({ debugGeography: -1 })).toThrowError(
|
|
15
|
+
"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('throws if options.tagForUnderAgeOfConsent is not a boolean.', function () {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
expect(() => AdsConsent.requestInfoUpdate({ tagForUnderAgeOfConsent: '123' })).toThrowError(
|
|
22
|
+
"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.",
|
|
15
23
|
);
|
|
16
24
|
});
|
|
17
25
|
|
|
18
|
-
it('throws if
|
|
26
|
+
it('throws if options.testDeviceIdentifiers is not an array', function () {
|
|
19
27
|
// @ts-ignore
|
|
20
|
-
expect(() => AdsConsent.requestInfoUpdate(
|
|
21
|
-
"AdsConsent.requestInfoUpdate(*) '
|
|
28
|
+
expect(() => AdsConsent.requestInfoUpdate({ testDeviceIdentifiers: '123' })).toThrowError(
|
|
29
|
+
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.",
|
|
22
30
|
);
|
|
23
31
|
});
|
|
24
32
|
});
|
package/android/build.gradle
CHANGED
|
@@ -22,6 +22,7 @@ plugins {
|
|
|
22
22
|
|
|
23
23
|
def packageJson = PackageJson.getForProject(project)
|
|
24
24
|
def googleMobileAdsVersion = packageJson['sdkVersions']['android']['googleMobileAds']
|
|
25
|
+
def googleUmpVersion = packageJson['sdkVersions']['android']['googleUmp']
|
|
25
26
|
def jsonMinSdk = packageJson['sdkVersions']['android']['minSdk']
|
|
26
27
|
def jsonTargetSdk = packageJson['sdkVersions']['android']['targetSdk']
|
|
27
28
|
def jsonCompileSdk = packageJson['sdkVersions']['android']['compileSdk']
|
|
@@ -44,7 +45,7 @@ project.ext {
|
|
|
44
45
|
],
|
|
45
46
|
|
|
46
47
|
ads : [
|
|
47
|
-
consent:
|
|
48
|
+
consent: googleUmpVersion,
|
|
48
49
|
],
|
|
49
50
|
],
|
|
50
51
|
])
|
|
@@ -88,8 +89,8 @@ repositories {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
dependencies {
|
|
91
|
-
implementation("com.google.android.gms:play-services-ads
|
|
92
|
-
|
|
92
|
+
implementation("com.google.android.gms:play-services-ads:${googleMobileAdsVersion}") { force = true; }
|
|
93
|
+
api "com.google.android.ump:user-messaging-platform:${googleUmpVersion}"
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
ReactNative.shared.applyPackageVersion()
|
package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java
CHANGED
|
@@ -31,6 +31,7 @@ import com.google.ads.mediation.admob.AdMobAdapter;
|
|
|
31
31
|
import com.google.android.gms.ads.AdError;
|
|
32
32
|
import com.google.android.gms.ads.AdRequest;
|
|
33
33
|
import com.google.android.gms.ads.AdSize;
|
|
34
|
+
import com.google.android.gms.ads.admanager.AdManagerAdRequest;
|
|
34
35
|
import io.invertase.googlemobileads.common.ReactNativeEventEmitter;
|
|
35
36
|
import java.util.ArrayList;
|
|
36
37
|
import java.util.Map;
|
|
@@ -130,8 +131,8 @@ public class ReactNativeGoogleMobileAdsCommon {
|
|
|
130
131
|
return map;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
public static
|
|
134
|
-
|
|
134
|
+
public static AdManagerAdRequest buildAdRequest(ReadableMap adRequestOptions) {
|
|
135
|
+
AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
|
|
135
136
|
Bundle extras = new Bundle();
|
|
136
137
|
|
|
137
138
|
if (adRequestOptions.hasKey("requestNonPersonalizedAdsOnly")
|
|
@@ -177,6 +178,16 @@ public class ReactNativeGoogleMobileAdsCommon {
|
|
|
177
178
|
builder.setRequestAgent(Objects.requireNonNull(adRequestOptions.getString("requestAgent")));
|
|
178
179
|
}
|
|
179
180
|
|
|
181
|
+
if (adRequestOptions.hasKey("customTargeting")) {
|
|
182
|
+
Map<String, Object> customTargeting = adRequestOptions.getMap("customTargeting").toHashMap();
|
|
183
|
+
|
|
184
|
+
for (Map.Entry<String, Object> entry : customTargeting.entrySet()) {
|
|
185
|
+
String key = entry.getKey();
|
|
186
|
+
String value = (String) entry.getValue();
|
|
187
|
+
builder.addCustomTargeting(key, value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
180
191
|
return builder.build();
|
|
181
192
|
}
|
|
182
193
|
|
|
@@ -21,206 +21,135 @@ import com.facebook.react.bridge.Arguments;
|
|
|
21
21
|
import com.facebook.react.bridge.Promise;
|
|
22
22
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
23
23
|
import com.facebook.react.bridge.ReactMethod;
|
|
24
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
25
24
|
import com.facebook.react.bridge.ReadableMap;
|
|
26
|
-
import com.facebook.react.bridge.WritableArray;
|
|
27
25
|
import com.facebook.react.bridge.WritableMap;
|
|
28
|
-
import com.google.
|
|
29
|
-
import com.google.
|
|
30
|
-
import com.google.
|
|
31
|
-
import com.google.
|
|
32
|
-
import com.google.ads.consent.ConsentInformation;
|
|
33
|
-
import com.google.ads.consent.ConsentStatus;
|
|
34
|
-
import com.google.ads.consent.DebugGeography;
|
|
26
|
+
import com.google.android.ump.ConsentDebugSettings;
|
|
27
|
+
import com.google.android.ump.ConsentInformation;
|
|
28
|
+
import com.google.android.ump.ConsentRequestParameters;
|
|
29
|
+
import com.google.android.ump.UserMessagingPlatform;
|
|
35
30
|
import io.invertase.googlemobileads.common.ReactNativeModule;
|
|
36
|
-
import java.net.MalformedURLException;
|
|
37
|
-
import java.net.URL;
|
|
38
31
|
import java.util.List;
|
|
32
|
+
import javax.annotation.Nonnull;
|
|
39
33
|
|
|
40
34
|
public class ReactNativeGoogleMobileAdsConsentModule extends ReactNativeModule {
|
|
35
|
+
|
|
41
36
|
private static final String TAG = "RNGoogleMobileAdsConsentModule";
|
|
42
37
|
private ConsentInformation consentInformation;
|
|
43
|
-
private ConsentForm consentForm;
|
|
44
38
|
|
|
45
39
|
public ReactNativeGoogleMobileAdsConsentModule(ReactApplicationContext reactContext) {
|
|
46
40
|
super(reactContext, TAG);
|
|
47
|
-
consentInformation =
|
|
41
|
+
consentInformation = UserMessagingPlatform.getConsentInformation(reactContext);
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
private
|
|
44
|
+
private String getConsentStatusString(int consentStatus) {
|
|
51
45
|
switch (consentStatus) {
|
|
52
|
-
case
|
|
53
|
-
return
|
|
54
|
-
case
|
|
55
|
-
return
|
|
56
|
-
case
|
|
46
|
+
case ConsentInformation.ConsentStatus.REQUIRED:
|
|
47
|
+
return "REQUIRED";
|
|
48
|
+
case ConsentInformation.ConsentStatus.NOT_REQUIRED:
|
|
49
|
+
return "NOT_REQUIRED";
|
|
50
|
+
case ConsentInformation.ConsentStatus.OBTAINED:
|
|
51
|
+
return "OBTAINED";
|
|
52
|
+
case ConsentInformation.ConsentStatus.UNKNOWN:
|
|
57
53
|
default:
|
|
58
|
-
return
|
|
54
|
+
return "UNKNOWN";
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
@ReactMethod
|
|
63
|
-
public void requestInfoUpdate(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
public void requestInfoUpdate(@Nonnull final ReadableMap options, final Promise promise) {
|
|
60
|
+
try {
|
|
61
|
+
ConsentRequestParameters.Builder paramsBuilder = new ConsentRequestParameters.Builder();
|
|
62
|
+
ConsentDebugSettings.Builder debugSettingsBuilder =
|
|
63
|
+
new ConsentDebugSettings.Builder(getApplicationContext());
|
|
64
|
+
|
|
65
|
+
if (options.hasKey("testDeviceIdentifiers")) {
|
|
66
|
+
List<Object> devices = options.getArray("testDeviceIdentifiers").toArrayList();
|
|
67
|
+
|
|
68
|
+
for (Object device : devices) {
|
|
69
|
+
debugSettingsBuilder.addTestDeviceHashedId((String) device);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (options.hasKey("debugGeography")) {
|
|
74
|
+
debugSettingsBuilder.setDebugGeography(options.getInt("debugGeography"));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
paramsBuilder.setConsentDebugSettings(debugSettingsBuilder.build());
|
|
78
|
+
|
|
79
|
+
if (options.hasKey("tagForUnderAgeOfConsent")) {
|
|
80
|
+
paramsBuilder.setTagForUnderAgeOfConsent(options.getBoolean("tagForUnderAgeOfConsent"));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ConsentRequestParameters consentRequestParameters = paramsBuilder.build();
|
|
84
|
+
|
|
85
|
+
if (getCurrentActivity() == null) {
|
|
86
|
+
rejectPromiseWithCodeAndMessage(
|
|
87
|
+
promise,
|
|
88
|
+
"null-activity",
|
|
89
|
+
"Attempted to request a consent info update but the current Activity was null.");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
consentInformation.requestConsentInfoUpdate(
|
|
94
|
+
getCurrentActivity(),
|
|
95
|
+
consentRequestParameters,
|
|
96
|
+
() -> {
|
|
72
97
|
WritableMap requestInfoMap = Arguments.createMap();
|
|
73
|
-
requestInfoMap.
|
|
98
|
+
requestInfoMap.putString(
|
|
99
|
+
"status", getConsentStatusString(consentInformation.getConsentStatus()));
|
|
74
100
|
requestInfoMap.putBoolean(
|
|
75
|
-
"
|
|
76
|
-
consentInformation.isRequestLocationInEeaOrUnknown());
|
|
101
|
+
"isConsentFormAvailable", consentInformation.isConsentFormAvailable());
|
|
77
102
|
promise.resolve(requestInfoMap);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@ReactMethod
|
|
88
|
-
public void showForm(ReadableMap options, Promise promise) {
|
|
89
|
-
if (getCurrentActivity() == null) {
|
|
90
|
-
rejectPromiseWithCodeAndMessage(
|
|
91
|
-
promise,
|
|
92
|
-
"null-activity",
|
|
93
|
-
"Consent form attempted to show but the current Activity was null.");
|
|
94
|
-
return;
|
|
103
|
+
},
|
|
104
|
+
formError ->
|
|
105
|
+
rejectPromiseWithCodeAndMessage(
|
|
106
|
+
promise, "consent-update-failed", formError.getMessage()));
|
|
107
|
+
} catch (Exception e) {
|
|
108
|
+
rejectPromiseWithCodeAndMessage(promise, "consent-update-failed", e.toString());
|
|
95
109
|
}
|
|
96
|
-
getCurrentActivity()
|
|
97
|
-
.runOnUiThread(
|
|
98
|
-
() -> {
|
|
99
|
-
URL privacyUrl = null;
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
privacyUrl = new URL(options.getString("privacyPolicy"));
|
|
103
|
-
} catch (MalformedURLException e) {
|
|
104
|
-
// Validated in JS land
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
ConsentFormListener listener =
|
|
108
|
-
new ConsentFormListener() {
|
|
109
|
-
@Override
|
|
110
|
-
public void onConsentFormLoaded() {
|
|
111
|
-
try {
|
|
112
|
-
consentForm.show();
|
|
113
|
-
} catch (Exception e) {
|
|
114
|
-
rejectPromiseWithCodeAndMessage(
|
|
115
|
-
promise, "consent-form-error", e.toString());
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@Override
|
|
120
|
-
public void onConsentFormClosed(
|
|
121
|
-
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
|
|
122
|
-
WritableMap consentFormMap = Arguments.createMap();
|
|
123
|
-
consentFormMap.putInt("status", getConsentStatusInt(consentStatus));
|
|
124
|
-
consentFormMap.putBoolean("userPrefersAdFree", userPrefersAdFree);
|
|
125
|
-
promise.resolve(consentFormMap);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@Override
|
|
129
|
-
public void onConsentFormError(String reason) {
|
|
130
|
-
rejectPromiseWithCodeAndMessage(promise, "consent-form-error", reason);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
ConsentForm.Builder builder =
|
|
135
|
-
new ConsentForm.Builder(getCurrentActivity(), privacyUrl).withListener(listener);
|
|
136
|
-
|
|
137
|
-
if (options.hasKey("withPersonalizedAds")
|
|
138
|
-
&& options.getBoolean("withPersonalizedAds")) {
|
|
139
|
-
builder = builder.withPersonalizedAdsOption();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (options.hasKey("withNonPersonalizedAds")
|
|
143
|
-
&& options.getBoolean("withNonPersonalizedAds")) {
|
|
144
|
-
builder = builder.withNonPersonalizedAdsOption();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (options.hasKey("withAdFree") && options.getBoolean("withAdFree")) {
|
|
148
|
-
builder = builder.withAdFreeOption();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
consentForm = builder.build();
|
|
152
|
-
consentForm.load();
|
|
153
|
-
});
|
|
154
110
|
}
|
|
155
111
|
|
|
156
112
|
@ReactMethod
|
|
157
|
-
public void
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
113
|
+
public void showForm(final Promise promise) {
|
|
114
|
+
try {
|
|
115
|
+
if (getCurrentActivity() == null) {
|
|
116
|
+
rejectPromiseWithCodeAndMessage(
|
|
117
|
+
promise,
|
|
118
|
+
"null-activity",
|
|
119
|
+
"Consent form attempted to show but the current Activity was null.");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
getCurrentActivity()
|
|
123
|
+
.runOnUiThread(
|
|
124
|
+
() ->
|
|
125
|
+
UserMessagingPlatform.loadConsentForm(
|
|
126
|
+
getReactApplicationContext(),
|
|
127
|
+
consentForm ->
|
|
128
|
+
consentForm.show(
|
|
129
|
+
getCurrentActivity(),
|
|
130
|
+
formError -> {
|
|
131
|
+
if (formError != null) {
|
|
132
|
+
rejectPromiseWithCodeAndMessage(
|
|
133
|
+
promise, "consent-form-error", formError.getMessage());
|
|
134
|
+
} else {
|
|
135
|
+
WritableMap consentFormMap = Arguments.createMap();
|
|
136
|
+
consentFormMap.putString(
|
|
137
|
+
"status",
|
|
138
|
+
getConsentStatusString(
|
|
139
|
+
consentInformation.getConsentStatus()));
|
|
140
|
+
promise.resolve(consentFormMap);
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
formError ->
|
|
144
|
+
rejectPromiseWithCodeAndMessage(
|
|
145
|
+
promise, "consent-form-error", formError.getMessage())));
|
|
146
|
+
} catch (Exception e) {
|
|
147
|
+
rejectPromiseWithCodeAndMessage(promise, "consent-form-error", e.toString());
|
|
176
148
|
}
|
|
177
|
-
|
|
178
|
-
consentInformation.setConsentStatus(consentStatus);
|
|
179
|
-
promise.resolve(null);
|
|
180
149
|
}
|
|
181
150
|
|
|
182
151
|
@ReactMethod
|
|
183
|
-
public void
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
WritableArray formattedAdProviders = Arguments.createArray();
|
|
187
|
-
|
|
188
|
-
for (AdProvider provider : providers) {
|
|
189
|
-
WritableMap formattedProvider = Arguments.createMap();
|
|
190
|
-
formattedProvider.putString("companyName", provider.getName());
|
|
191
|
-
formattedProvider.putString("companyId", provider.getId());
|
|
192
|
-
formattedProvider.putString("privacyPolicyUrl", provider.getPrivacyPolicyUrlString());
|
|
193
|
-
formattedAdProviders.pushMap(formattedProvider);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
promise.resolve(formattedAdProviders);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
@ReactMethod
|
|
200
|
-
public void setTagForUnderAgeOfConsent(boolean tag, Promise promise) {
|
|
201
|
-
consentInformation.setTagForUnderAgeOfConsent(tag);
|
|
202
|
-
promise.resolve(null);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
@ReactMethod
|
|
206
|
-
public void setDebugGeography(int geography, Promise promise) {
|
|
207
|
-
if (geography == 0) {
|
|
208
|
-
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_DISABLED);
|
|
209
|
-
} else if (geography == 1) {
|
|
210
|
-
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
|
|
211
|
-
} else if (geography == 2) {
|
|
212
|
-
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_NOT_EEA);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
promise.resolve(null);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
@ReactMethod
|
|
219
|
-
public void addTestDevices(ReadableArray deviceIds, Promise promise) {
|
|
220
|
-
List<Object> devices = deviceIds.toArrayList();
|
|
221
|
-
for (Object device : devices) {
|
|
222
|
-
consentInformation.addTestDevice((String) device);
|
|
223
|
-
}
|
|
224
|
-
promise.resolve(null);
|
|
152
|
+
public void reset() {
|
|
153
|
+
consentInformation.reset();
|
|
225
154
|
}
|
|
226
155
|
}
|
package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java
CHANGED
|
@@ -117,7 +117,7 @@ public class ReactNativeGoogleMobileAdsModule extends ReactNativeModule {
|
|
|
117
117
|
@ReactMethod
|
|
118
118
|
public void initialize(Promise promise) {
|
|
119
119
|
MobileAds.initialize(
|
|
120
|
-
|
|
120
|
+
getApplicationContext(),
|
|
121
121
|
new OnInitializationCompleteListener() {
|
|
122
122
|
@Override
|
|
123
123
|
public void onInitializationComplete(InitializationStatus initializationStatus) {
|