react-native-google-mobile-ads
Advanced tools
Comparing version 4.2.0 to 5.0.0
@@ -5,22 +5,30 @@ import { AdsConsent } from '../src'; | ||
describe('requestInfoUpdate', function () { | ||
it('throws if publisherIds is not an array', function () { | ||
it('throws if options are not an object', function () { | ||
// @ts-ignore | ||
expect(() => AdsConsent.requestInfoUpdate('pub-123')).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.", | ||
expect(() => AdsConsent.requestInfoUpdate('123')).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'options' expected an object value.", | ||
); | ||
}); | ||
it('throws if publisherIds is empty array', function () { | ||
expect(() => AdsConsent.requestInfoUpdate([])).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.", | ||
it('throws if options.debugGeography is not a valid value.', function () { | ||
// @ts-ignore | ||
expect(() => AdsConsent.requestInfoUpdate({ debugGeography: -1 })).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.", | ||
); | ||
}); | ||
it('throws if publisherIds contains non-string values', function () { | ||
it('throws if options.tagForUnderAgeOfConsent is not a boolean.', function () { | ||
// @ts-ignore | ||
expect(() => AdsConsent.requestInfoUpdate(['foo', 123])).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'publisherIds[1]' expected a string value.", | ||
expect(() => AdsConsent.requestInfoUpdate({ tagForUnderAgeOfConsent: '123' })).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.", | ||
); | ||
}); | ||
it('throws if options.testDeviceIdentifiers is not an array', function () { | ||
// @ts-ignore | ||
expect(() => AdsConsent.requestInfoUpdate({ testDeviceIdentifiers: '123' })).toThrowError( | ||
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.", | ||
); | ||
}); | ||
}); | ||
}); |
@@ -8,4 +8,5 @@ { | ||
["European User Consent", "/european-user-consent"], | ||
["Common Reasons For Ads Not Showing", "/common-reasons-for-ads-not-showing"] | ||
["Common Reasons For Ads Not Showing", "/common-reasons-for-ads-not-showing"], | ||
["Migrating to v5", "/migrating-to-v5"] | ||
] | ||
} |
@@ -14,4 +14,2 @@ "use strict"; | ||
var _AdsConsentStatus = require("./AdsConsentStatus"); | ||
/* | ||
@@ -37,54 +35,38 @@ * Copyright (c) 2016-present Invertase Limited & Contributors | ||
* | ||
* @param publisherIds | ||
* @returns {*} | ||
* @param {Object} [options] | ||
* @param {AdsConsentDebugGeography} [options.debugGeography] | ||
* @param {Boolean} [options.tagForUnderAgeOfConsent] | ||
* @param {Array<String>} [options.testDeviceIdentifiers] | ||
* @returns {{ status: Number, isConsentFormAvailable: Boolean }} | ||
*/ | ||
requestInfoUpdate(publisherIds) { | ||
if (!(0, _common.isArray)(publisherIds)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values."); | ||
} | ||
requestInfoUpdate() { | ||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (publisherIds.length === 0) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty."); | ||
if (!(0, _common.isObject)(options)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value."); | ||
} | ||
for (let i = 0; i < publisherIds.length; i++) { | ||
if (!(0, _common.isString)(publisherIds[i])) { | ||
throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`); | ||
} | ||
if ((0, _common.hasOwnProperty)(options, 'debugGeography') && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA."); | ||
} | ||
return native.requestInfoUpdate(publisherIds); | ||
}, | ||
/** | ||
* | ||
* @param options | ||
* @returns {*} | ||
*/ | ||
showForm(options) { | ||
if (!(0, _common.isUndefined)(options) && !(0, _common.isObject)(options)) { | ||
throw new Error("AdsConsent.showForm(*) 'options' expected an object value."); | ||
if ((0, _common.hasOwnProperty)(options, 'tagForUnderAgeOfConsent') && !(0, _common.isBoolean)(options.tagForUnderAgeOfConsent)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value."); | ||
} | ||
if (!(0, _common.isValidUrl)(options.privacyPolicy)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL."); | ||
} | ||
if ((0, _common.hasOwnProperty)(options, 'testDeviceIdentifiers')) { | ||
if (!(0, _common.isArray)(options.testDeviceIdentifiers)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); | ||
} | ||
if ((0, _common.hasOwnProperty)(options, 'withPersonalizedAds') && !(0, _common.isBoolean)(options.withPersonalizedAds)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value."); | ||
} | ||
for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) { | ||
var _options$testDeviceId; | ||
if ((0, _common.hasOwnProperty)(options, 'withNonPersonalizedAds') && !(0, _common.isBoolean)(options.withNonPersonalizedAds)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value."); | ||
if (!(0, _common.isString)(deviceId)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); | ||
} | ||
} | ||
} | ||
if ((0, _common.hasOwnProperty)(options, 'withAdFree') && !(0, _common.isBoolean)(options.withAdFree)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value."); | ||
} | ||
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) { | ||
throw new Error("AdsConsent.showForm(*) 'options' form requires at least one option to be enabled."); | ||
} | ||
return native.showForm(options); | ||
return native.requestInfoUpdate(options); | ||
}, | ||
@@ -94,5 +76,6 @@ | ||
* | ||
* @returns {{ status: Number }} | ||
*/ | ||
getAdProviders() { | ||
return native.getAdProviders(); | ||
showForm() { | ||
return native.showForm(); | ||
}, | ||
@@ -102,59 +85,5 @@ | ||
* | ||
* @param geography | ||
*/ | ||
setDebugGeography(geography) { | ||
if (geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) { | ||
throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA."); | ||
} | ||
return native.setDebugGeography(geography); | ||
}, | ||
/** | ||
* | ||
*/ | ||
getStatus() { | ||
return native.getStatus(); | ||
}, | ||
/** | ||
* | ||
* @param status | ||
*/ | ||
setStatus(status) { | ||
if (status !== _AdsConsentStatus.AdsConsentStatus.UNKNOWN && status !== _AdsConsentStatus.AdsConsentStatus.NON_PERSONALIZED && status !== _AdsConsentStatus.AdsConsentStatus.PERSONALIZED) { | ||
throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED."); | ||
} | ||
return native.setStatus(status); | ||
}, | ||
/** | ||
* | ||
* @param tag | ||
*/ | ||
setTagForUnderAgeOfConsent(tag) { | ||
if (!(0, _common.isBoolean)(tag)) { | ||
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value."); | ||
} | ||
return native.setTagForUnderAgeOfConsent(tag); | ||
}, | ||
/** | ||
* | ||
* @param deviceIds | ||
*/ | ||
addTestDevices(deviceIds) { | ||
if (!(0, _common.isArray)(deviceIds)) { | ||
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values."); | ||
} | ||
for (let i = 0; i < deviceIds.length; i++) { | ||
if (!(0, _common.isString)(deviceIds[i])) { | ||
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values."); | ||
} | ||
} | ||
return native.addTestDevices(deviceIds); | ||
reset() { | ||
return native.reset(); | ||
} | ||
@@ -161,0 +90,0 @@ |
@@ -32,6 +32,7 @@ "use strict"; | ||
(function (AdsConsentStatus) { | ||
AdsConsentStatus[AdsConsentStatus["UNKNOWN"] = 0] = "UNKNOWN"; | ||
AdsConsentStatus[AdsConsentStatus["NON_PERSONALIZED"] = 1] = "NON_PERSONALIZED"; | ||
AdsConsentStatus[AdsConsentStatus["PERSONALIZED"] = 2] = "PERSONALIZED"; | ||
AdsConsentStatus["UNKNOWN"] = "UNKNOWN"; | ||
AdsConsentStatus["REQUIRED"] = "REQUIRED"; | ||
AdsConsentStatus["NOT_REQUIRED"] = "NOT_REQUIRED"; | ||
AdsConsentStatus["OBTAINED"] = "OBTAINED"; | ||
})(AdsConsentStatus || (exports.AdsConsentStatus = AdsConsentStatus = {})); | ||
//# sourceMappingURL=AdsConsentStatus.js.map |
@@ -8,4 +8,4 @@ "use strict"; | ||
// generated by genversion | ||
const version = '4.2.0'; | ||
const version = '5.0.0'; | ||
exports.version = version; | ||
//# sourceMappingURL=version.js.map |
@@ -17,6 +17,5 @@ /* | ||
*/ | ||
import { hasOwnProperty, isArray, isBoolean, isObject, isString, isUndefined, isValidUrl } from './common'; | ||
import { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common'; | ||
import { NativeModules } from 'react-native'; | ||
import { AdsConsentDebugGeography } from './AdsConsentDebugGeography'; | ||
import { AdsConsentStatus } from './AdsConsentStatus'; | ||
const native = NativeModules.RNGoogleMobileAdsConsentModule; | ||
@@ -26,54 +25,38 @@ export const AdsConsent = { | ||
* | ||
* @param publisherIds | ||
* @returns {*} | ||
* @param {Object} [options] | ||
* @param {AdsConsentDebugGeography} [options.debugGeography] | ||
* @param {Boolean} [options.tagForUnderAgeOfConsent] | ||
* @param {Array<String>} [options.testDeviceIdentifiers] | ||
* @returns {{ status: Number, isConsentFormAvailable: Boolean }} | ||
*/ | ||
requestInfoUpdate(publisherIds) { | ||
if (!isArray(publisherIds)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values."); | ||
} | ||
requestInfoUpdate() { | ||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (publisherIds.length === 0) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty."); | ||
if (!isObject(options)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value."); | ||
} | ||
for (let i = 0; i < publisherIds.length; i++) { | ||
if (!isString(publisherIds[i])) { | ||
throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`); | ||
} | ||
if (hasOwnProperty(options, 'debugGeography') && options.debugGeography !== AdsConsentDebugGeography.DISABLED && options.debugGeography !== AdsConsentDebugGeography.EEA && options.debugGeography !== AdsConsentDebugGeography.NOT_EEA) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA."); | ||
} | ||
return native.requestInfoUpdate(publisherIds); | ||
}, | ||
/** | ||
* | ||
* @param options | ||
* @returns {*} | ||
*/ | ||
showForm(options) { | ||
if (!isUndefined(options) && !isObject(options)) { | ||
throw new Error("AdsConsent.showForm(*) 'options' expected an object value."); | ||
if (hasOwnProperty(options, 'tagForUnderAgeOfConsent') && !isBoolean(options.tagForUnderAgeOfConsent)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value."); | ||
} | ||
if (!isValidUrl(options.privacyPolicy)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL."); | ||
} | ||
if (hasOwnProperty(options, 'testDeviceIdentifiers')) { | ||
if (!isArray(options.testDeviceIdentifiers)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); | ||
} | ||
if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value."); | ||
} | ||
for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) { | ||
var _options$testDeviceId; | ||
if (hasOwnProperty(options, 'withNonPersonalizedAds') && !isBoolean(options.withNonPersonalizedAds)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value."); | ||
if (!isString(deviceId)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); | ||
} | ||
} | ||
} | ||
if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value."); | ||
} | ||
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) { | ||
throw new Error("AdsConsent.showForm(*) 'options' form requires at least one option to be enabled."); | ||
} | ||
return native.showForm(options); | ||
return native.requestInfoUpdate(options); | ||
}, | ||
@@ -83,5 +66,6 @@ | ||
* | ||
* @returns {{ status: Number }} | ||
*/ | ||
getAdProviders() { | ||
return native.getAdProviders(); | ||
showForm() { | ||
return native.showForm(); | ||
}, | ||
@@ -91,59 +75,5 @@ | ||
* | ||
* @param geography | ||
*/ | ||
setDebugGeography(geography) { | ||
if (geography !== AdsConsentDebugGeography.DISABLED && geography !== AdsConsentDebugGeography.EEA && geography !== AdsConsentDebugGeography.NOT_EEA) { | ||
throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA."); | ||
} | ||
return native.setDebugGeography(geography); | ||
}, | ||
/** | ||
* | ||
*/ | ||
getStatus() { | ||
return native.getStatus(); | ||
}, | ||
/** | ||
* | ||
* @param status | ||
*/ | ||
setStatus(status) { | ||
if (status !== AdsConsentStatus.UNKNOWN && status !== AdsConsentStatus.NON_PERSONALIZED && status !== AdsConsentStatus.PERSONALIZED) { | ||
throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED."); | ||
} | ||
return native.setStatus(status); | ||
}, | ||
/** | ||
* | ||
* @param tag | ||
*/ | ||
setTagForUnderAgeOfConsent(tag) { | ||
if (!isBoolean(tag)) { | ||
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value."); | ||
} | ||
return native.setTagForUnderAgeOfConsent(tag); | ||
}, | ||
/** | ||
* | ||
* @param deviceIds | ||
*/ | ||
addTestDevices(deviceIds) { | ||
if (!isArray(deviceIds)) { | ||
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values."); | ||
} | ||
for (let i = 0; i < deviceIds.length; i++) { | ||
if (!isString(deviceIds[i])) { | ||
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values."); | ||
} | ||
} | ||
return native.addTestDevices(deviceIds); | ||
reset() { | ||
return native.reset(); | ||
} | ||
@@ -150,0 +80,0 @@ |
@@ -24,6 +24,7 @@ /* | ||
(function (AdsConsentStatus) { | ||
AdsConsentStatus[AdsConsentStatus["UNKNOWN"] = 0] = "UNKNOWN"; | ||
AdsConsentStatus[AdsConsentStatus["NON_PERSONALIZED"] = 1] = "NON_PERSONALIZED"; | ||
AdsConsentStatus[AdsConsentStatus["PERSONALIZED"] = 2] = "PERSONALIZED"; | ||
AdsConsentStatus["UNKNOWN"] = "UNKNOWN"; | ||
AdsConsentStatus["REQUIRED"] = "REQUIRED"; | ||
AdsConsentStatus["NOT_REQUIRED"] = "NOT_REQUIRED"; | ||
AdsConsentStatus["OBTAINED"] = "OBTAINED"; | ||
})(AdsConsentStatus || (AdsConsentStatus = {})); | ||
//# sourceMappingURL=AdsConsentStatus.js.map |
// generated by genversion | ||
export const version = '4.2.0'; | ||
export const version = '5.0.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -6,13 +6,17 @@ /** | ||
/** | ||
* The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown. | ||
* Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it. | ||
*/ | ||
UNKNOWN = 0, | ||
UNKNOWN = "UNKNOWN", | ||
/** | ||
* The user has accepted non-personalized ads. | ||
* User consent required but not yet obtained. | ||
*/ | ||
NON_PERSONALIZED = 1, | ||
REQUIRED = "REQUIRED", | ||
/** | ||
* The user has accepted personalized ads. | ||
* User consent not required. | ||
*/ | ||
PERSONALIZED = 2 | ||
NOT_REQUIRED = "NOT_REQUIRED", | ||
/** | ||
* User consent already obtained. | ||
*/ | ||
OBTAINED = "OBTAINED" | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "4.2.0"; | ||
export declare const SDK_VERSION = "5.0.0"; | ||
export { default, MobileAds } from './MobileAds'; | ||
@@ -3,0 +3,0 @@ export { AdsConsentDebugGeography } from './AdsConsentDebugGeography'; |
@@ -12,41 +12,10 @@ import { AdsConsentDebugGeography } from '../AdsConsentDebugGeography'; | ||
* | ||
* For more information, see [here](https://developers.google.com/admob/android/eu-consent#delay_app_measurement_optional). | ||
* For more information, see [here](https://developers.google.com/admob/ump/android/quick-start#delay_app_measurement_optional). | ||
*/ | ||
/** | ||
* A AdProvider interface returned from `AdsConsent.getProviders`. | ||
*/ | ||
export interface AdProvider { | ||
/** | ||
* A provider company ID. | ||
*/ | ||
companyId: string; | ||
/** | ||
* A provider company name. | ||
*/ | ||
companyName: string; | ||
/** | ||
* A fully formed URL for the privacy policy of the provider. | ||
*/ | ||
privacyPolicyUrl: string; | ||
} | ||
export interface AdsConsentInterface { | ||
/** | ||
* Requests user consent for a given list of publisher IDs. | ||
* Requests user consent information. | ||
* | ||
* The list of publisher IDs can be obtained from the settings panel on the Google Mobile Ads console. If the list of | ||
* publisher IDs has changed since the last time a user provided consent, their consent status will be reset to | ||
* 'UNKNOWN' and they must provide consent again. | ||
* The response from this method provides information about consent form availability and consent status. | ||
* | ||
* If the request fails with the error "Could not parse Event FE preflight response", this means the state of your | ||
* Google Mobile Ads account is not complete. Ensure you have validated your account and have setup valid payment | ||
* information. This error is also thrown when a Publisher ID is invalid. | ||
* | ||
* The response from this method provides request location and consent status properties. | ||
* | ||
* If request location is within the EEA or unknown, and the consent status is also unknown, you | ||
* must request consent via the `showForm()` method or your own means. | ||
* | ||
* If the consent status is not unknown, the user has already previously provided consent for the current publisher | ||
* scope. | ||
* | ||
* #### Example | ||
@@ -57,32 +26,12 @@ * | ||
* | ||
* const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']); | ||
* console.log('User location within EEA or Unknown:', consent.isRequestLocationInEeaOrUnknown); | ||
* console.log('User consent status:', consent.status); | ||
* const consentInfo = await AdsConsent.requestInfoUpdate(); | ||
* console.log('A consent form is available:', consentInfo.isConsentFormAvailable); | ||
* console.log('User consent status:', consentInfo.status); | ||
* ``` | ||
* | ||
* @param publisherIds A list of publisher IDs found on your Google Mobile Ads dashboard. | ||
* @param options An AdsConsentInfoOptions interface. | ||
*/ | ||
requestInfoUpdate(publisherIds: string[]): Promise<AdsConsentInfo>; | ||
requestInfoUpdate(options?: AdsConsentInfoOptions): Promise<AdsConsentInfo>; | ||
/** | ||
* Shows a Google-rendered user consent form. | ||
* | ||
* The Google-rendered consent form is a full-screen configurable form that displays over your app content. The form | ||
* allows the following configuration options: | ||
* | ||
* | ||
* 1. Consent to view personalized ads (via `withPersonalizedAds`). | ||
* 2. Consent to view non-personalized ads (via `withNonPersonalizedAds`). | ||
* 3. Use a paid version of the app instead of viewing ads (via `withAdFree`). | ||
* | ||
* Every consent form requires a privacy policy URL which outlines the usage of your application. | ||
* | ||
* You should review the consent text carefully: what appears by default is a message that might be appropriate if | ||
* you use Google to monetize your app. | ||
* | ||
* If providing an ad-free version of your app, ensure you handle this once the form has been handled by the user | ||
* via the `userPrefersAdFree` property. The users preference on consent is automatically forwarded onto the Google | ||
* Mobile SDKs and saved. | ||
* | ||
* If the user is outside of the EEA, the request form will error. | ||
* | ||
* #### Example | ||
@@ -94,17 +43,13 @@ * | ||
* async function requestConsent() { | ||
* const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']); | ||
* const consentInfo = await AdsConsent.requestInfoUpdate(); | ||
* | ||
* // Check if user requires consent | ||
* if (consent.isRequestLocationInEeaOrUnknown && consent.status === AdsConsentStatus.UNKNOWN) { | ||
* if ( | ||
* consentInfo.isConsentFormAvailable && | ||
* (consentInfo.status === AdsConsentStatus.UNKNOWN || | ||
* consentInfo.status === AdsConsentStatus.REQUIRED)) { | ||
* // Show a Google-rendered form | ||
* const result = await AdsConsent.showForm({ | ||
* privacyPolicy: 'https://invertase.io/privacy-policy', | ||
* withPersonalizedAds: true, | ||
* withNonPersonalizedAds: true, | ||
* withAdFree: true, | ||
* }); | ||
* const formResult = await AdsConsent.showForm(); | ||
* | ||
* console.log('User accepted personalized: ', result.status === AdsConsentStatus.PERSONALIZED); | ||
* console.log('User accepted non-personalized: ', result.status === AdsConsentStatus.NON_PERSONALIZED); | ||
* console.log('User prefers Ad Free version of app: ', result.userPrefersAdFree); | ||
* console.log('User consent obtained: ', formResult.status === AdsConsentStatus.OBTAINED); | ||
* } | ||
@@ -114,143 +59,33 @@ * } | ||
* ``` | ||
* | ||
* @param options An AdsConsentFormOptions interface to control the Google-rendered form. | ||
*/ | ||
showForm(options: AdsConsentFormOptions): Promise<AdsConsentFormResult>; | ||
showForm(): Promise<AdsConsentFormResult>; | ||
/** | ||
* Returns a list of ad providers currently in use for the given Google Mobile Ads App ID. | ||
* Resets the UMP SDK state. | ||
* | ||
* If requesting consent from the user via your own method, this list of ad providers must be shown to the user | ||
* for them to accept consent. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* import { AdsConsent } from '@invertase/react-native-google-ads'; | ||
* | ||
* const providers = await AdsConsent.getAdProviders(); | ||
* AdsConsent.reset(); | ||
* ``` | ||
*/ | ||
getAdProviders(): Promise<AdProvider[]>; | ||
/** | ||
* Sets the debug geography to locally test consent. | ||
* | ||
* If debugging on an emulator (where location cannot be determined) or outside of the EEA, | ||
* it is possible set your own location to test how your app handles different scenarios. | ||
* | ||
* If using a real device, ensure you have set it as a test device via `addTestDevice()` otherwise this method will have | ||
* no effect. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads'; | ||
* | ||
* // Set disabled | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.DISABLED); | ||
* | ||
* // Set within EEA | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.EEA); | ||
* | ||
* // Set outside EEA | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.NOT_EEA); | ||
* ``` | ||
* | ||
* @param geography The debug geography location. | ||
*/ | ||
setDebugGeography(geography: AdsConsentDebugGeography): Promise<void>; | ||
/** | ||
* Manually update the consent status of the user. | ||
* | ||
* This method is used when providing your own means of user consent. If using the Google-rendered form via `showForm()`, | ||
* the consent status is automatically set and calling this method is not required. | ||
* | ||
* This method can also be used to reset the consent status, by setting it to `AdsConsentStatus.UNKNOWN`, which may be useful in certain circumstances. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads'; | ||
* | ||
* // User accepted personalized ads | ||
* await AdsConsent.setStatus(AdsConsentStatus.PERSONALIZED); | ||
* ``` | ||
* | ||
* @param status The user consent status. | ||
*/ | ||
setStatus(status: AdsConsentStatus): Promise<void>; | ||
/** | ||
* Returns the current consent status of the user. | ||
* | ||
* > The user consent status may change at any time, therefore don't reuse old values locally and always request the current value at any time consent is required. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* | ||
* const status = await AdsConsent.getStatus(); | ||
* ``` | ||
*/ | ||
getStatus(): Promise<AdsConsentStatus>; | ||
/** | ||
* If a publisher is aware that the user is under the age of consent, all ad requests must set TFUA (Tag For Users | ||
* Under the Age of consent in Europe). This setting takes effect for all future ad requests. | ||
* | ||
* Once the TFUA setting is enabled, the Google-rendered consent form will fail to load. All ad requests that include | ||
* TFUA will be made ineligible for personalized advertising and remarketing. TFUA disables requests to third-party | ||
* ad technology providers, such as ad measurement pixels and third-party ad servers. | ||
* | ||
* To remove TFUA from ad requests, set the value to `false`. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* | ||
* // User is under age of consent | ||
* await AdsConsent.setTagForUnderAgeOfConsent(true); | ||
* ``` | ||
* | ||
* @param tag The boolean value to tag for under age consent. | ||
*/ | ||
setTagForUnderAgeOfConsent(tag: boolean): Promise<void>; | ||
/** | ||
* If using a real device to test, ensure the device ID is provided to the Google Mobile Ads SDK so any mock debug locations | ||
* can take effect. | ||
* | ||
* Emulators are automatically on the allowlist and should require no action. | ||
* | ||
* If you are seeing real ad activity from a test device, examine logcat / console | ||
* during execution in association with google mobile ads test device documentation to | ||
* configure your device correctly. | ||
* | ||
* @param deviceIds An array of testing device ID. | ||
*/ | ||
addTestDevices(deviceIds: string[]): Promise<void>; | ||
reset(): void; | ||
} | ||
/** | ||
* The options used to show on the Google-rendered consent form. At least one of `withAdFree`, `withPersonalizedAds` and `WithNonPersonalizedAds` needs to be set to `true`. | ||
* The options used when requesting consent information. | ||
*/ | ||
export interface AdsConsentFormOptions { | ||
export interface AdsConsentInfoOptions { | ||
/** | ||
* A fully formed HTTP or HTTPS privacy policy URL for your application. | ||
* | ||
* Users will have the option to visit this web page before consenting to ads. | ||
* Sets the debug geography to locally test consent. | ||
*/ | ||
privacyPolicy: string; | ||
debugGeography?: AdsConsentDebugGeography; | ||
/** | ||
* Set to `true` to provide the option for the user to accept being shown personalized ads, defaults to `false`. | ||
*/ | ||
withPersonalizedAds?: boolean; | ||
tagForUnderAgeOfConsent?: boolean; | ||
/** | ||
* Set to `true` to provide the option for the user to accept being shown non-personalized ads, defaults to `false`. | ||
* An array of test device IDs to allow. | ||
*/ | ||
withNonPersonalizedAds?: boolean; | ||
/** | ||
* Set to `true` to provide the option for the user to choose an ad-free version of your app, defaults to `false`. | ||
* | ||
* If the user chooses this option, you must handle it as required (e.g. navigating to a paid version of the app, | ||
* or a subscribe view). | ||
*/ | ||
withAdFree?: boolean; | ||
testDeviceIdentifiers?: string[]; | ||
} | ||
@@ -264,11 +99,8 @@ /** | ||
* | ||
* - UNKNOWN: The form was unable to determine the users consent status. | ||
* - NON_PERSONALIZED: The user has accepted non-personalized ads. | ||
* - PERSONALIZED: The user has accepted personalized ads. | ||
* - `UNKNOWN`: Unknown consent status. | ||
* - `REQUIRED`: User consent required but not yet obtained. | ||
* - `NOT_REQUIRED`: User consent not required. | ||
* - `OBTAINED`: User consent already obtained. | ||
*/ | ||
status: AdsConsentStatus; | ||
/** | ||
* If `true`, the user requested an ad-free version of your application. | ||
*/ | ||
userPrefersAdFree: boolean; | ||
} | ||
@@ -282,11 +114,12 @@ /** | ||
* | ||
* - UNKNOWN: The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown. | ||
* - NON_PERSONALIZED: The user has accepted non-personalized ads. | ||
* - PERSONALIZED: The user has accepted personalized ads. | ||
* - `UNKNOWN`: Unknown consent status. | ||
* - `REQUIRED`: User consent required but not yet obtained. | ||
* - `NOT_REQUIRED`: User consent not required. | ||
* - `OBTAINED`: User consent already obtained. | ||
*/ | ||
status: AdsConsentStatus; | ||
/** | ||
* If `true` the user is within the EEA or their location could not be determined. | ||
* If `true` a consent form is available. | ||
*/ | ||
isRequestLocationInEeaOrUnknown: boolean; | ||
isConsentFormAvailable: boolean; | ||
} |
@@ -1,1 +0,1 @@ | ||
export declare const version = "4.2.0"; | ||
export declare const version = "5.0.0"; |
{ | ||
"name": "react-native-google-mobile-ads", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"author": "Invertase <oss@invertase.io> (http://invertase.io)", | ||
@@ -44,3 +44,4 @@ "description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.", | ||
"ios": { | ||
"googleAds": "8.13.0" | ||
"googleMobileAds": "8.13.0", | ||
"googleUmp": "2.0.0" | ||
}, | ||
@@ -52,3 +53,4 @@ "android": { | ||
"buildTools": "31.0.0", | ||
"googleAds": "19.8.0" | ||
"googleMobileAds": "20.5.0", | ||
"googleUmp": "2.0.0" | ||
} | ||
@@ -55,0 +57,0 @@ }, |
@@ -18,14 +18,5 @@ /* | ||
import { | ||
hasOwnProperty, | ||
isArray, | ||
isBoolean, | ||
isObject, | ||
isString, | ||
isUndefined, | ||
isValidUrl, | ||
} from './common'; | ||
import { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common'; | ||
import { NativeModules } from 'react-native'; | ||
import { AdsConsentDebugGeography } from './AdsConsentDebugGeography'; | ||
import { AdsConsentStatus } from './AdsConsentStatus'; | ||
import { AdsConsentInterface } from './types/AdsConsent.interface'; | ||
@@ -38,121 +29,50 @@ | ||
* | ||
* @param publisherIds | ||
* @returns {*} | ||
* @param {Object} [options] | ||
* @param {AdsConsentDebugGeography} [options.debugGeography] | ||
* @param {Boolean} [options.tagForUnderAgeOfConsent] | ||
* @param {Array<String>} [options.testDeviceIdentifiers] | ||
* @returns {{ status: Number, isConsentFormAvailable: Boolean }} | ||
*/ | ||
requestInfoUpdate(publisherIds) { | ||
if (!isArray(publisherIds)) { | ||
throw new Error( | ||
"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.", | ||
); | ||
requestInfoUpdate(options = {}) { | ||
if (!isObject(options)) { | ||
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value."); | ||
} | ||
if (publisherIds.length === 0) { | ||
throw new Error( | ||
"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.", | ||
); | ||
} | ||
for (let i = 0; i < publisherIds.length; i++) { | ||
if (!isString(publisherIds[i])) { | ||
throw new Error( | ||
`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`, | ||
); | ||
} | ||
} | ||
return native.requestInfoUpdate(publisherIds); | ||
}, | ||
/** | ||
* | ||
* @param options | ||
* @returns {*} | ||
*/ | ||
showForm(options) { | ||
if (!isUndefined(options) && !isObject(options)) { | ||
throw new Error("AdsConsent.showForm(*) 'options' expected an object value."); | ||
} | ||
if (!isValidUrl(options.privacyPolicy)) { | ||
throw new Error( | ||
"AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.", | ||
); | ||
} | ||
if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) { | ||
throw new Error( | ||
"AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.", | ||
); | ||
} | ||
if ( | ||
hasOwnProperty(options, 'withNonPersonalizedAds') && | ||
!isBoolean(options.withNonPersonalizedAds) | ||
hasOwnProperty(options, 'debugGeography') && | ||
options.debugGeography !== AdsConsentDebugGeography.DISABLED && | ||
options.debugGeography !== AdsConsentDebugGeography.EEA && | ||
options.debugGeography !== AdsConsentDebugGeography.NOT_EEA | ||
) { | ||
throw new Error( | ||
"AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.", | ||
"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.", | ||
); | ||
} | ||
if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) { | ||
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value."); | ||
} | ||
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) { | ||
throw new Error( | ||
"AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.", | ||
); | ||
} | ||
return native.showForm(options); | ||
}, | ||
/** | ||
* | ||
*/ | ||
getAdProviders() { | ||
return native.getAdProviders(); | ||
}, | ||
/** | ||
* | ||
* @param geography | ||
*/ | ||
setDebugGeography(geography) { | ||
if ( | ||
geography !== AdsConsentDebugGeography.DISABLED && | ||
geography !== AdsConsentDebugGeography.EEA && | ||
geography !== AdsConsentDebugGeography.NOT_EEA | ||
hasOwnProperty(options, 'tagForUnderAgeOfConsent') && | ||
!isBoolean(options.tagForUnderAgeOfConsent) | ||
) { | ||
throw new Error( | ||
"AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.", | ||
"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.", | ||
); | ||
} | ||
return native.setDebugGeography(geography); | ||
}, | ||
if (hasOwnProperty(options, 'testDeviceIdentifiers')) { | ||
if (!isArray(options.testDeviceIdentifiers)) { | ||
throw new Error( | ||
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.", | ||
); | ||
} | ||
/** | ||
* | ||
*/ | ||
getStatus() { | ||
return native.getStatus(); | ||
}, | ||
/** | ||
* | ||
* @param status | ||
*/ | ||
setStatus(status) { | ||
if ( | ||
status !== AdsConsentStatus.UNKNOWN && | ||
status !== AdsConsentStatus.NON_PERSONALIZED && | ||
status !== AdsConsentStatus.PERSONALIZED | ||
) { | ||
throw new Error( | ||
"AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.", | ||
); | ||
for (const deviceId of options.testDeviceIdentifiers ?? []) { | ||
if (!isString(deviceId)) { | ||
throw new Error( | ||
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.", | ||
); | ||
} | ||
} | ||
} | ||
return native.setStatus(status); | ||
return native.requestInfoUpdate(options); | ||
}, | ||
@@ -162,10 +82,6 @@ | ||
* | ||
* @param tag | ||
* @returns {{ status: Number }} | ||
*/ | ||
setTagForUnderAgeOfConsent(tag) { | ||
if (!isBoolean(tag)) { | ||
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value."); | ||
} | ||
return native.setTagForUnderAgeOfConsent(tag); | ||
showForm() { | ||
return native.showForm(); | ||
}, | ||
@@ -175,21 +91,6 @@ | ||
* | ||
* @param deviceIds | ||
*/ | ||
addTestDevices(deviceIds) { | ||
if (!isArray(deviceIds)) { | ||
throw new Error( | ||
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.", | ||
); | ||
} | ||
for (let i = 0; i < deviceIds.length; i++) { | ||
if (!isString(deviceIds[i])) { | ||
throw new Error( | ||
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.", | ||
); | ||
} | ||
} | ||
return native.addTestDevices(deviceIds); | ||
reset() { | ||
return native.reset(); | ||
}, | ||
}; |
@@ -23,15 +23,20 @@ /* | ||
/** | ||
* The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown. | ||
* Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it. | ||
*/ | ||
UNKNOWN = 0, | ||
UNKNOWN = 'UNKNOWN', | ||
/** | ||
* The user has accepted non-personalized ads. | ||
* User consent required but not yet obtained. | ||
*/ | ||
NON_PERSONALIZED = 1, | ||
REQUIRED = 'REQUIRED', | ||
/** | ||
* The user has accepted personalized ads. | ||
* User consent not required. | ||
*/ | ||
PERSONALIZED = 2, | ||
NOT_REQUIRED = 'NOT_REQUIRED', | ||
/** | ||
* User consent already obtained. | ||
*/ | ||
OBTAINED = 'OBTAINED', | ||
} |
@@ -13,45 +13,11 @@ import { AdsConsentDebugGeography } from '../AdsConsentDebugGeography'; | ||
* | ||
* For more information, see [here](https://developers.google.com/admob/android/eu-consent#delay_app_measurement_optional). | ||
* For more information, see [here](https://developers.google.com/admob/ump/android/quick-start#delay_app_measurement_optional). | ||
*/ | ||
/** | ||
* A AdProvider interface returned from `AdsConsent.getProviders`. | ||
*/ | ||
export interface AdProvider { | ||
/** | ||
* A provider company ID. | ||
*/ | ||
companyId: string; | ||
/** | ||
* A provider company name. | ||
*/ | ||
companyName: string; | ||
/** | ||
* A fully formed URL for the privacy policy of the provider. | ||
*/ | ||
privacyPolicyUrl: string; | ||
} | ||
export interface AdsConsentInterface { | ||
/** | ||
* Requests user consent for a given list of publisher IDs. | ||
* Requests user consent information. | ||
* | ||
* The list of publisher IDs can be obtained from the settings panel on the Google Mobile Ads console. If the list of | ||
* publisher IDs has changed since the last time a user provided consent, their consent status will be reset to | ||
* 'UNKNOWN' and they must provide consent again. | ||
* The response from this method provides information about consent form availability and consent status. | ||
* | ||
* If the request fails with the error "Could not parse Event FE preflight response", this means the state of your | ||
* Google Mobile Ads account is not complete. Ensure you have validated your account and have setup valid payment | ||
* information. This error is also thrown when a Publisher ID is invalid. | ||
* | ||
* The response from this method provides request location and consent status properties. | ||
* | ||
* If request location is within the EEA or unknown, and the consent status is also unknown, you | ||
* must request consent via the `showForm()` method or your own means. | ||
* | ||
* If the consent status is not unknown, the user has already previously provided consent for the current publisher | ||
* scope. | ||
* | ||
* #### Example | ||
@@ -62,10 +28,9 @@ * | ||
* | ||
* const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']); | ||
* console.log('User location within EEA or Unknown:', consent.isRequestLocationInEeaOrUnknown); | ||
* console.log('User consent status:', consent.status); | ||
* const consentInfo = await AdsConsent.requestInfoUpdate(); | ||
* console.log('A consent form is available:', consentInfo.isConsentFormAvailable); | ||
* console.log('User consent status:', consentInfo.status); | ||
* ``` | ||
* | ||
* @param publisherIds A list of publisher IDs found on your Google Mobile Ads dashboard. | ||
* @param options An AdsConsentInfoOptions interface. | ||
*/ | ||
requestInfoUpdate(publisherIds: string[]): Promise<AdsConsentInfo>; | ||
requestInfoUpdate(options?: AdsConsentInfoOptions): Promise<AdsConsentInfo>; | ||
@@ -75,21 +40,2 @@ /** | ||
* | ||
* The Google-rendered consent form is a full-screen configurable form that displays over your app content. The form | ||
* allows the following configuration options: | ||
* | ||
* | ||
* 1. Consent to view personalized ads (via `withPersonalizedAds`). | ||
* 2. Consent to view non-personalized ads (via `withNonPersonalizedAds`). | ||
* 3. Use a paid version of the app instead of viewing ads (via `withAdFree`). | ||
* | ||
* Every consent form requires a privacy policy URL which outlines the usage of your application. | ||
* | ||
* You should review the consent text carefully: what appears by default is a message that might be appropriate if | ||
* you use Google to monetize your app. | ||
* | ||
* If providing an ad-free version of your app, ensure you handle this once the form has been handled by the user | ||
* via the `userPrefersAdFree` property. The users preference on consent is automatically forwarded onto the Google | ||
* Mobile SDKs and saved. | ||
* | ||
* If the user is outside of the EEA, the request form will error. | ||
* | ||
* #### Example | ||
@@ -101,17 +47,13 @@ * | ||
* async function requestConsent() { | ||
* const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']); | ||
* const consentInfo = await AdsConsent.requestInfoUpdate(); | ||
* | ||
* // Check if user requires consent | ||
* if (consent.isRequestLocationInEeaOrUnknown && consent.status === AdsConsentStatus.UNKNOWN) { | ||
* if ( | ||
* consentInfo.isConsentFormAvailable && | ||
* (consentInfo.status === AdsConsentStatus.UNKNOWN || | ||
* consentInfo.status === AdsConsentStatus.REQUIRED)) { | ||
* // Show a Google-rendered form | ||
* const result = await AdsConsent.showForm({ | ||
* privacyPolicy: 'https://invertase.io/privacy-policy', | ||
* withPersonalizedAds: true, | ||
* withNonPersonalizedAds: true, | ||
* withAdFree: true, | ||
* }); | ||
* const formResult = await AdsConsent.showForm(); | ||
* | ||
* console.log('User accepted personalized: ', result.status === AdsConsentStatus.PERSONALIZED); | ||
* console.log('User accepted non-personalized: ', result.status === AdsConsentStatus.NON_PERSONALIZED); | ||
* console.log('User prefers Ad Free version of app: ', result.userPrefersAdFree); | ||
* console.log('User consent obtained: ', formResult.status === AdsConsentStatus.OBTAINED); | ||
* } | ||
@@ -121,135 +63,27 @@ * } | ||
* ``` | ||
* | ||
* @param options An AdsConsentFormOptions interface to control the Google-rendered form. | ||
*/ | ||
showForm(options: AdsConsentFormOptions): Promise<AdsConsentFormResult>; | ||
showForm(): Promise<AdsConsentFormResult>; | ||
/** | ||
* Returns a list of ad providers currently in use for the given Google Mobile Ads App ID. | ||
* Resets the UMP SDK state. | ||
* | ||
* If requesting consent from the user via your own method, this list of ad providers must be shown to the user | ||
* for them to accept consent. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* import { AdsConsent } from '@invertase/react-native-google-ads'; | ||
* | ||
* const providers = await AdsConsent.getAdProviders(); | ||
* AdsConsent.reset(); | ||
* ``` | ||
*/ | ||
getAdProviders(): Promise<AdProvider[]>; | ||
/** | ||
* Sets the debug geography to locally test consent. | ||
* | ||
* If debugging on an emulator (where location cannot be determined) or outside of the EEA, | ||
* it is possible set your own location to test how your app handles different scenarios. | ||
* | ||
* If using a real device, ensure you have set it as a test device via `addTestDevice()` otherwise this method will have | ||
* no effect. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads'; | ||
* | ||
* // Set disabled | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.DISABLED); | ||
* | ||
* // Set within EEA | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.EEA); | ||
* | ||
* // Set outside EEA | ||
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.NOT_EEA); | ||
* ``` | ||
* | ||
* @param geography The debug geography location. | ||
*/ | ||
setDebugGeography(geography: AdsConsentDebugGeography): Promise<void>; | ||
/** | ||
* Manually update the consent status of the user. | ||
* | ||
* This method is used when providing your own means of user consent. If using the Google-rendered form via `showForm()`, | ||
* the consent status is automatically set and calling this method is not required. | ||
* | ||
* This method can also be used to reset the consent status, by setting it to `AdsConsentStatus.UNKNOWN`, which may be useful in certain circumstances. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads'; | ||
* | ||
* // User accepted personalized ads | ||
* await AdsConsent.setStatus(AdsConsentStatus.PERSONALIZED); | ||
* ``` | ||
* | ||
* @param status The user consent status. | ||
*/ | ||
setStatus(status: AdsConsentStatus): Promise<void>; | ||
/** | ||
* Returns the current consent status of the user. | ||
* | ||
* > The user consent status may change at any time, therefore don't reuse old values locally and always request the current value at any time consent is required. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* | ||
* const status = await AdsConsent.getStatus(); | ||
* ``` | ||
*/ | ||
getStatus(): Promise<AdsConsentStatus>; | ||
/** | ||
* If a publisher is aware that the user is under the age of consent, all ad requests must set TFUA (Tag For Users | ||
* Under the Age of consent in Europe). This setting takes effect for all future ad requests. | ||
* | ||
* Once the TFUA setting is enabled, the Google-rendered consent form will fail to load. All ad requests that include | ||
* TFUA will be made ineligible for personalized advertising and remarketing. TFUA disables requests to third-party | ||
* ad technology providers, such as ad measurement pixels and third-party ad servers. | ||
* | ||
* To remove TFUA from ad requests, set the value to `false`. | ||
* | ||
* #### Example | ||
* | ||
* ```js | ||
* import { AdsConsent } from 'react-native-google-mobile-ads'; | ||
* | ||
* // User is under age of consent | ||
* await AdsConsent.setTagForUnderAgeOfConsent(true); | ||
* ``` | ||
* | ||
* @param tag The boolean value to tag for under age consent. | ||
*/ | ||
setTagForUnderAgeOfConsent(tag: boolean): Promise<void>; | ||
/** | ||
* If using a real device to test, ensure the device ID is provided to the Google Mobile Ads SDK so any mock debug locations | ||
* can take effect. | ||
* | ||
* Emulators are automatically on the allowlist and should require no action. | ||
* | ||
* If you are seeing real ad activity from a test device, examine logcat / console | ||
* during execution in association with google mobile ads test device documentation to | ||
* configure your device correctly. | ||
* | ||
* @param deviceIds An array of testing device ID. | ||
*/ | ||
addTestDevices(deviceIds: string[]): Promise<void>; | ||
reset(): void; | ||
} | ||
/** | ||
* The options used to show on the Google-rendered consent form. At least one of `withAdFree`, `withPersonalizedAds` and `WithNonPersonalizedAds` needs to be set to `true`. | ||
* The options used when requesting consent information. | ||
*/ | ||
export interface AdsConsentFormOptions { | ||
export interface AdsConsentInfoOptions { | ||
/** | ||
* A fully formed HTTP or HTTPS privacy policy URL for your application. | ||
* | ||
* Users will have the option to visit this web page before consenting to ads. | ||
* Sets the debug geography to locally test consent. | ||
*/ | ||
privacyPolicy: string; | ||
debugGeography?: AdsConsentDebugGeography; | ||
@@ -259,16 +93,8 @@ /** | ||
*/ | ||
withPersonalizedAds?: boolean; | ||
tagForUnderAgeOfConsent?: boolean; | ||
/** | ||
* Set to `true` to provide the option for the user to accept being shown non-personalized ads, defaults to `false`. | ||
* An array of test device IDs to allow. | ||
*/ | ||
withNonPersonalizedAds?: boolean; | ||
/** | ||
* Set to `true` to provide the option for the user to choose an ad-free version of your app, defaults to `false`. | ||
* | ||
* If the user chooses this option, you must handle it as required (e.g. navigating to a paid version of the app, | ||
* or a subscribe view). | ||
*/ | ||
withAdFree?: boolean; | ||
testDeviceIdentifiers?: string[]; | ||
} | ||
@@ -283,12 +109,8 @@ | ||
* | ||
* - UNKNOWN: The form was unable to determine the users consent status. | ||
* - NON_PERSONALIZED: The user has accepted non-personalized ads. | ||
* - PERSONALIZED: The user has accepted personalized ads. | ||
* - `UNKNOWN`: Unknown consent status. | ||
* - `REQUIRED`: User consent required but not yet obtained. | ||
* - `NOT_REQUIRED`: User consent not required. | ||
* - `OBTAINED`: User consent already obtained. | ||
*/ | ||
status: AdsConsentStatus; | ||
/** | ||
* If `true`, the user requested an ad-free version of your application. | ||
*/ | ||
userPrefersAdFree: boolean; | ||
} | ||
@@ -303,5 +125,6 @@ | ||
* | ||
* - UNKNOWN: The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown. | ||
* - NON_PERSONALIZED: The user has accepted non-personalized ads. | ||
* - PERSONALIZED: The user has accepted personalized ads. | ||
* - `UNKNOWN`: Unknown consent status. | ||
* - `REQUIRED`: User consent required but not yet obtained. | ||
* - `NOT_REQUIRED`: User consent not required. | ||
* - `OBTAINED`: User consent already obtained. | ||
*/ | ||
@@ -311,5 +134,5 @@ status: AdsConsentStatus; | ||
/** | ||
* If `true` the user is within the EEA or their location could not be determined. | ||
* If `true` a consent form is available. | ||
*/ | ||
isRequestLocationInEeaOrUnknown: boolean; | ||
isConsentFormAvailable: boolean; | ||
} |
// generated by genversion | ||
export const version = '4.2.0'; | ||
export const version = '5.0.0'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375
879151
9408