react-native-appodeal
Version:
React Native Module created to support Appodeal SDK for iOS and Android platforms
180 lines (174 loc) • 5.79 kB
JavaScript
;
/**
* Appodeal SDK for React Native
*
* This module provides a complete interface to the Appodeal SDK for React Native applications.
* It includes functionality for:
* - Ad management (banner, interstitial, rewarded video, MREC)
* - Analytics and revenue tracking
* - In-app purchase validation
* - Consent management (GDPR compliance)
* - Event handling and callbacks
*
* The module uses React Native TurboModules for optimal performance and type safety.
*/
// Appodeal types and interfaces
import { AppodealAdType } from "./types/index.js";
// Native module and validation types
import NativeAppodeal from "./specs/NativeAppodealModule.js";
// Event manager
import AppodealEventManagerInstance from "./RNAppodealEventManager.js";
// Type definitions
/**
* Appodeal SDK interface using Turbo modules
*/
/**
* Plugin version constant
*/
const PLUGIN_VERSION = '3.8.1';
/**
* Appodeal SDK implementation
*
* This object implements all the methods defined in the Appodeal interface.
* Each method delegates to the corresponding native module method with proper
* parameter handling and type conversion.
*/
const appodeal = {
addEventListener: (event, handler) => {
return AppodealEventManagerInstance.addEventListener(event, handler);
},
removeEventListener: (event, handler) => {
AppodealEventManagerInstance.removeEventListener(event, handler);
},
removeAllListeners: () => {
AppodealEventManagerInstance.removeAllListeners();
},
initialize: (appKey, adTypes) => {
NativeAppodeal.initialize(appKey, adTypes, PLUGIN_VERSION);
},
isInitialized: adTypes => {
return NativeAppodeal.isInitialized(adTypes);
},
show: (adTypes, placement) => {
NativeAppodeal.show(adTypes, placement || 'default');
},
isLoaded: adTypes => {
return NativeAppodeal.isLoaded(adTypes);
},
canShow: (adTypes, placement) => {
return NativeAppodeal.canShow(adTypes, placement || 'default');
},
hide: adTypes => {
NativeAppodeal.hide(adTypes);
},
cache: adTypes => {
NativeAppodeal.cache(adTypes);
},
setAutoCache: (adTypes, value) => {
NativeAppodeal.setAutoCache(adTypes, value);
},
isPrecache: adTypes => {
return NativeAppodeal.isPrecache(adTypes);
},
setTabletBanners: value => {
NativeAppodeal.setTabletBanners(value);
},
setSmartBanners: value => {
NativeAppodeal.setSmartBanners(value);
},
setBannerAnimation: value => {
NativeAppodeal.setBannerAnimation(value);
},
consentStatus: () => {
return NativeAppodeal.consentStatus();
},
revokeConsent: () => {
NativeAppodeal.revokeConsent();
},
requestConsentInfoUpdate: appKey => {
return NativeAppodeal.requestConsentInfoUpdateWithAppKey(appKey).then(parameters => parameters.status);
},
showConsentFormIfNeeded: () => {
return NativeAppodeal.showConsentFormIfNeeded().then(parameters => parameters.status);
},
showConsentForm: () => {
return NativeAppodeal.showConsentForm().then(parameters => parameters.status);
},
setChildDirectedTreatment: value => {
NativeAppodeal.setChildDirectedTreatment(value);
},
setTesting: value => {
NativeAppodeal.setTesting(value);
},
setLogLevel: value => {
NativeAppodeal.setLogLevel(value);
},
setTriggerPrecacheCallbacks: (adTypes, value) => {
NativeAppodeal.setTriggerPrecacheCallbacks(adTypes, value);
},
disableNetwork: (network, adTypes = AppodealAdType.ALL) => {
NativeAppodeal.disableNetwork(network, adTypes);
},
getVersion: () => {
return PLUGIN_VERSION;
},
getPlatformSdkVersion: () => {
return NativeAppodeal.getPlatformSdkVersion();
},
setUserId: id => {
NativeAppodeal.setUserId(id);
},
setExtrasValue: (key, value) => {
if (typeof value === 'string') {
NativeAppodeal.setExtrasStringValue(key, value);
} else if (typeof value === 'number' && Number.isInteger(value)) {
NativeAppodeal.setExtrasIntegerValue(key, value);
} else if (typeof value === 'number') {
NativeAppodeal.setExtrasDoubleValue(key, value);
} else if (typeof value === 'boolean') {
NativeAppodeal.setExtrasBooleanValue(key, value);
} else if (typeof value === 'object') {
NativeAppodeal.setExtrasMapValue(key, value);
} else if (value === null) {
NativeAppodeal.removeExtrasValue(key);
}
},
setCustomStateValue: (key, value) => {
if (typeof value === 'string') {
NativeAppodeal.setCustomStateStringValue(key, value);
} else if (typeof value === 'number' && Number.isInteger(value)) {
NativeAppodeal.setCustomStateIntegerValue(key, value);
} else if (typeof value === 'number') {
NativeAppodeal.setCustomStateDoubleValue(key, value);
} else if (typeof value === 'boolean') {
NativeAppodeal.setCustomStateBooleanValue(key, value);
} else if (typeof value === 'object') {
NativeAppodeal.setCustomStateMapValue(key, value);
} else if (value === null) {
NativeAppodeal.removeCustomStateValue(key);
}
},
getRewardParameters: placement => {
return NativeAppodeal.getRewardParameters(placement || 'default');
},
predictedEcpm: adType => {
return NativeAppodeal.predictedEcpm(adType);
},
trackInAppPurchase: (amount, currency) => {
NativeAppodeal.trackInAppPurchase(amount, currency);
},
validateAndTrackInAppPurchase: purchase => {
return NativeAppodeal.validateAndTrackInAppPurchase(purchase);
},
trackEvent: (name, parameters = {}) => {
NativeAppodeal.trackEvent(name, parameters);
},
setBidonEndpoint: endpoint => {
NativeAppodeal.setBidonEndpoint(endpoint);
},
getBidonEndpoint: () => {
return NativeAppodeal.getBidonEndpoint();
}
};
export default appodeal;
//# sourceMappingURL=RNAppodeal.js.map