UNPKG

react-native-google-mobile-ads

Version:

React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.

110 lines (108 loc) 5.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AdsConsent = void 0; var _core = require("@iabtcf/core"); var _reactNative = require("react-native"); var _AdsConsentDebugGeography = require("./AdsConsentDebugGeography"); var _AdsConsentPurposes = require("./AdsConsentPurposes"); var _AdsConsentSpecialFeatures = require("./AdsConsentSpecialFeatures"); var _common = require("./common"); /* * Copyright (c) 2016-present Invertase Limited & Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this library except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ const native = _reactNative.NativeModules.RNGoogleMobileAdsConsentModule; const AdsConsent = exports.AdsConsent = { requestInfoUpdate(options = {}) { if (!(0, _common.isObject)(options)) { throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value."); } if ((0, _common.isPropertySet)(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."); } if ((0, _common.isPropertySet)(options, 'tagForUnderAgeOfConsent') && !(0, _common.isBoolean)(options.tagForUnderAgeOfConsent)) { throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value."); } if ((0, _common.isPropertySet)(options, 'testDeviceIdentifiers')) { if (!(0, _common.isArray)(options.testDeviceIdentifiers)) { throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); } for (const deviceId of options.testDeviceIdentifiers ?? []) { if (!(0, _common.isString)(deviceId)) { throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values."); } } } return native.requestInfoUpdate(options); }, showForm() { return native.showForm(); }, showPrivacyOptionsForm() { return native.showPrivacyOptionsForm(); }, loadAndShowConsentFormIfRequired() { return native.loadAndShowConsentFormIfRequired(); }, getConsentInfo() { return native.getConsentInfo(); }, reset() { return native.reset(); }, getTCString() { return native.getTCString(); }, async getTCModel() { const tcString = await native.getTCString(); return _core.TCString.decode(tcString); }, getGdprApplies() { return native.getGdprApplies(); }, getPurposeConsents() { return native.getPurposeConsents(); }, async getUserChoices() { const tcString = await native.getTCString(); let tcModel; try { tcModel = _core.TCString.decode(tcString); } catch (e) { tcModel = new _core.TCModel(); if (__DEV__) { // eslint-disable-next-line no-console console.warn(`Failed to decode tcString ${tcString}:`, e); } } return { activelyScanDeviceCharacteristicsForIdentification: tcModel.specialFeatureOptins.has(_AdsConsentSpecialFeatures.AdsConsentSpecialFeatures.ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION), applyMarketResearchToGenerateAudienceInsights: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS), createAPersonalisedAdsProfile: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE), createAPersonalisedContentProfile: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.CREATE_A_PERSONALISED_CONTENT_PROFILE), developAndImproveProducts: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.DEVELOP_AND_IMPROVE_PRODUCTS), measureAdPerformance: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.MEASURE_AD_PERFORMANCE), measureContentPerformance: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.MEASURE_CONTENT_PERFORMANCE), selectBasicAds: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_BASIC_ADS), selectPersonalisedAds: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_PERSONALISED_ADS), selectPersonalisedContent: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_PERSONALISED_CONTENT), storeAndAccessInformationOnDevice: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.STORE_AND_ACCESS_INFORMATION_ON_DEVICE), usePreciseGeolocationData: tcModel.specialFeatureOptins.has(_AdsConsentSpecialFeatures.AdsConsentSpecialFeatures.USE_PRECISE_GEOLOCATION_DATA) }; } }; //# sourceMappingURL=AdsConsent.js.map