diff --git a/RNAmazonPublisherServices.podspec b/RNAmazonPublisherServices.podspec index 6fcb9bd..608b443 100644 --- a/RNAmazonPublisherServices.podspec +++ b/RNAmazonPublisherServices.podspec @@ -21,7 +21,8 @@ Pod::Spec.new do |s| # folly_version must match the version used in React Native # See folly_version in react-native/React/FBReactNativeSpec/FBReactNativeSpec.podspec - folly_version = '2021.06.28.00-v2' + folly_config = get_folly_config() + folly_version = folly_config[:version] folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' s.compiler_flags = folly_compiler_flags diff --git a/package.json b/package.json index 60cf8c2..66a8eca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-aps", - "version": "2.0.1", + "version": "2.0.3", "author": "AdversportTeam (https://github.com/AdversportTeam)", "contributors": [ "Jay Kim (https://github.com/wjaykim)" @@ -257,12 +257,8 @@ ] }, "codegenConfig": { - "libraries": [ - { - "name": "rnaps", - "type": "modules", - "jsSrcsDir": "./src/turbomodules" - } - ] + "name": "rnaps", + "type": "modules", + "jsSrcsDir": "./src/turbomodules" } } diff --git a/src/APSAds.ts b/src/APSAds.ts index cd23734..ba89e45 100644 --- a/src/APSAds.ts +++ b/src/APSAds.ts @@ -20,17 +20,11 @@ import AdsModule from './internal/AdsModule'; import { AdNetworkInfo, validateAdNetworkInfo } from './types/AdNetworkInfo'; import { isMRAIDPolicy, MRAIDPolicy } from './types/MRAIDPolicy'; -/** - * @public - */ export class APSAds { private static _nativeModule = AdsModule; /** * Initializes the APSAds SDK. - * @param appKey - Generated APS app key from the APS portal - * - * @public */ static initialize(appKey: string): Promise { if (typeof appKey !== 'string') { @@ -41,9 +35,6 @@ export class APSAds { /** * Sets the primary ad server or mediator. - * @param adNetworkInfo - `AdNetworkInfo` object containing the primary ad network and its properties - * - * @public */ static setAdNetworkInfo(adNetworkInfo: AdNetworkInfo): void { try { @@ -58,9 +49,6 @@ export class APSAds { /** * Sets the MRAID versions supported by user ad server. - * @param versions - Array of supported versions - * - * @public */ static setMRAIDSupportedVersions(versions: string[]): void { if ( @@ -76,9 +64,6 @@ export class APSAds { /** * Sets the MRAID policy. - * @param policy - MRAIDPolicy value. `MRAIDPolicy.DFP` for Google Ad Manager and `MRAIDPolicy.CUSTOM` for other ad server / mediation. - * - * @public */ static setMRAIDPolicy(policy: MRAIDPolicy): void { if (!isMRAIDPolicy(policy)) { @@ -91,9 +76,6 @@ export class APSAds { /** * Enable / disable the test mode for APSAds. - * @param enabled - Whether to enable or disable the test mode. - * - * @public */ static setTestMode(enabled: boolean): void { if (typeof enabled !== 'boolean') { @@ -106,9 +88,6 @@ export class APSAds { /** * Enable / disable the geo location tracking for APSAds. - * @param enabled - Whether to enable or disable the geo location tracking. - * - * @public */ static setUseGeoLocation(enabled: boolean): void { if (typeof enabled !== 'boolean') { @@ -121,10 +100,6 @@ export class APSAds { /** * Adds a custom attribute to the APSAds SDK. - * @param key - The key of the custom attribute - * @param value - The value of the custom attribute - * - * @public */ static addCustomAttribute(key: string, value: string): void { if (typeof key !== 'string') { @@ -142,9 +117,6 @@ export class APSAds { /** * Removes a custom attribute from the APSAds SDK. - * @param key - The key of the custom attribute - * - * @public */ static removeCustomAttribute(key: string): void { if (typeof key !== 'string') { diff --git a/src/AdError.ts b/src/AdError.ts index e110f7b..fd85fec 100644 --- a/src/AdError.ts +++ b/src/AdError.ts @@ -19,20 +19,13 @@ /** * AdError class * - * @public */ export class AdError extends Error { - /** - * @internal - */ constructor(readonly code: string, message: string) { super(message); this.name = 'AdError'; } - /** - * @internal - */ static fromNativeError(error: any): AdError { const { code, message } = error.userInfo; return new AdError(code, message); @@ -41,10 +34,6 @@ export class AdError extends Error { /** * Type guard for AdError. - * @param error - Uknown error object - * @returns Whether the error is an AdError - * - * @public */ export function isAdError(error: unknown): error is AdError { return error instanceof AdError; diff --git a/src/AdLoader.ts b/src/AdLoader.ts index 1973b19..bc0c440 100644 --- a/src/AdLoader.ts +++ b/src/AdLoader.ts @@ -27,11 +27,8 @@ import { validateAdLoaderOptions, validateBannerAdLoaderOptions, } from './types/AdLoaderOptions'; -import { AdType } from './types/AdType'; +import { AdType } from './types'; -/** - * @public - */ export class AdLoader { private static readonly _nativeModule = AdLoaderModule; private static readonly _eventEmitter = new NativeEventEmitter( @@ -49,8 +46,6 @@ export class AdLoader { /** * Create a banner AdLoader instance. - * @param adLoaderOptions - `BannerAdLoaderOptions` object used to configure the bid request. - * @returns AdLoader instance. */ static createBannerAdLoader(adLoaderOptions: BannerAdLoaderOptions) { try { @@ -66,8 +61,6 @@ export class AdLoader { /** * Create a interstitial AdLoader instance. - * @param adLoaderOptions - `AdLoaderOptions` object used to configure the bid request. - * @returns AdLoader instance. */ static createInterstitialAdLoader(adLoaderOptions: AdLoaderOptions) { try { @@ -85,12 +78,6 @@ export class AdLoader { * Add a listener for the bid response. Supported events are: * - `AdLoaderEvent.SUCCESS` * - `AdLoaderEvent.FAILURE` - * @param eventName - The name of the event to listen. - * @param listener - The listener to be called when the event is fired. - * - * @returns Unsubscribe function. - * - * @public */ addListener( eventName: E, @@ -126,9 +113,6 @@ export class AdLoader { * Request APS for a bid. Only a single ad size and slotUUID is supported per bid request. * This method will return a promise that resolves a bid response requested by this call. * In order to receive further bid responses returned by auto refresh, you must register listeners via `addListener()`. - * @returns Promise of key value pairs from returned bid response. - * - * @public */ async loadAd() { try { @@ -149,7 +133,6 @@ export class AdLoader { /** * Stop the auto refresh of the ad. * - * @public */ stopAutoRefresh() { AdLoader._nativeModule.stopAutoRefresh(this.loaderId); @@ -157,10 +140,6 @@ export class AdLoader { /** * In order for SKAdNetwork to work, pass the app event. - * @param name - The name of the event. - * @param info - The data/info with the event. - * - * @public */ static skadnHelper(name: string, info?: string) { if (typeof name !== 'string') { diff --git a/src/TestIds.ts b/src/TestIds.ts index 564fd14..c1802b3 100644 --- a/src/TestIds.ts +++ b/src/TestIds.ts @@ -18,9 +18,6 @@ import { Platform } from 'react-native'; -/** - * @public - */ export const TestIds = { APS_APP_KEY: '', APS_SLOT_BANNER_320x50: '', diff --git a/src/turbomodules/NativeRNAPSAdLoaderModule.ts b/src/turbomodules/NativeRNAPSAdLoaderModule.ts index 76b1d99..b6be6c7 100644 --- a/src/turbomodules/NativeRNAPSAdLoaderModule.ts +++ b/src/turbomodules/NativeRNAPSAdLoaderModule.ts @@ -16,15 +16,42 @@ * along with Foobar. If not, see . */ -import { TurboModule, TurboModuleRegistry } from 'react-native'; +import type { TurboModule } from 'react-native'; +import { TurboModuleRegistry } from 'react-native'; -import type { AdLoaderOptions, AdType, BannerAdLoaderOptions } from '../types'; +interface AdLoaderOptions { + /** + * The slotUUID of the ad slot. + */ + slotUUID: string; + /** + * The optional custom targeting key value pairs for the bid request. + */ + customTargeting?: { [key: string]: string }; +} + +interface BannerAdLoaderOptions extends AdLoaderOptions { + /** + * The size of the banner ad slot. Required for banner ad slots. + */ + size?: string; + + /** + * Whether the banner ad to be automatically refreshed. Defaults to `false`. + */ + autoRefresh?: boolean; + + /** + * The time interval in seconds between refreshes. Defaults to `60` seconds if autoRefresh enabled. The minimum auto-refresh time supported is `20` seconds. + */ + refreshInterval?: number; +} export interface Spec extends TurboModule { loadAd: ( loaderId: number, - adType: AdType, - options: AdLoaderOptions | BannerAdLoaderOptions + adType: string, + options: BannerAdLoaderOptions ) => Promise<{ [key: string]: string }>; stopAutoRefresh: (loaderId: number) => void; @@ -32,4 +59,4 @@ export interface Spec extends TurboModule { skadnHelper: (name: string, info?: string) => void; } -export default TurboModuleRegistry.get('RNAPSAdLoaderModule'); +export default TurboModuleRegistry.getEnforcing('RNAPSAdLoaderModule'); diff --git a/src/turbomodules/NativeRNAPSAdsModule.ts b/src/turbomodules/NativeRNAPSAdsModule.ts index 7e3e265..bbcbf61 100644 --- a/src/turbomodules/NativeRNAPSAdsModule.ts +++ b/src/turbomodules/NativeRNAPSAdsModule.ts @@ -15,10 +15,16 @@ * You should have received a copy of the GNU Lesser General Public License * along with Foobar. If not, see . */ - -import { TurboModule, TurboModuleRegistry } from 'react-native'; - -import type { AdNetworkInfo, MRAIDPolicy } from '../types'; +import type { TurboModule } from 'react-native'; +import { TurboModuleRegistry } from 'react-native'; + +interface AdNetworkInfo { + /** + * The name of the primary ad server or mediator + */ + adNetwork: string; + adNetworkProperties?: { [key: string]: string }; +} /** * @internal @@ -30,7 +36,7 @@ export interface Spec extends TurboModule { setMRAIDSupportedVersions: (supportedVersions: string[]) => void; - setMRAIDPolicy: (policy: MRAIDPolicy) => void; + setMRAIDPolicy: (policy: string) => void; setTestMode: (enabled: boolean) => void; @@ -41,4 +47,4 @@ export interface Spec extends TurboModule { removeCustomAttribute: (key: string) => void; } -export default TurboModuleRegistry.get('RNAPSAdsModule'); +export default TurboModuleRegistry.getEnforcing('RNAPSAdsModule'); diff --git a/src/types/AdLoaderEvent.ts b/src/types/AdLoaderEvent.ts index aeb8e90..593741a 100644 --- a/src/types/AdLoaderEvent.ts +++ b/src/types/AdLoaderEvent.ts @@ -16,22 +16,13 @@ * along with Foobar. If not, see . */ -/** - * @public - */ export const AdLoaderEvent = { SUCCESS: 'onSuccess', FAILURE: 'onFailure', } as const; -/** - * @public - */ export type AdLoaderEvent = typeof AdLoaderEvent[keyof typeof AdLoaderEvent]; -/** - * @internal - */ export function isAdLoaderEvent(value: any): value is AdLoaderEvent { return Object.values(AdLoaderEvent).includes(value); } diff --git a/src/types/AdLoaderOptions.ts b/src/types/AdLoaderOptions.ts index 55bb055..ec13c6e 100644 --- a/src/types/AdLoaderOptions.ts +++ b/src/types/AdLoaderOptions.ts @@ -16,9 +16,6 @@ * along with Foobar. If not, see . */ -/** - * @public - */ export interface AdLoaderOptions { /** * The slotUUID of the ad slot. @@ -30,14 +27,11 @@ export interface AdLoaderOptions { customTargeting?: { [key: string]: string }; } -/** - * @public - */ export interface BannerAdLoaderOptions extends AdLoaderOptions { /** * The size of the banner ad slot. Required for banner ad slots. */ - size: string; + size?: string; /** * Whether the banner ad to be automatically refreshed. Defaults to `false`. @@ -52,9 +46,6 @@ export interface BannerAdLoaderOptions extends AdLoaderOptions { const sizeRegex = /([0-9]+)x([0-9]+)/; -/** - * @internal - */ export function validateAdLoaderOptions(adLoaderOptions: AdLoaderOptions) { if (typeof adLoaderOptions !== 'object') { throw new Error("'adLoaderOptions' expected an object value"); @@ -64,9 +55,6 @@ export function validateAdLoaderOptions(adLoaderOptions: AdLoaderOptions) { } } -/** - * @internal - */ export function validateBannerAdLoaderOptions( adLoaderOptions: BannerAdLoaderOptions ) { diff --git a/src/types/AdNetwork.ts b/src/types/AdNetwork.ts index b72b83f..be76bf8 100644 --- a/src/types/AdNetwork.ts +++ b/src/types/AdNetwork.ts @@ -16,27 +16,16 @@ * along with Foobar. If not, see . */ -/** - * @public - */ -export const AdNetwork = { - GOOGLE_AD_MANAGER: 'GOOGLE_AD_MANAGER', - ADMOB: 'ADMOB', - AD_GENERATION: 'AD_GENERATION', - IRON_SOURCE: 'IRON_SOURCE', - MAX: 'MAX', - NIMBUS: 'NIMBUS', - OTHER: 'OTHER', -} as const; - -/** - * @public - */ -export type AdNetwork = typeof AdNetwork[keyof typeof AdNetwork]; +export enum AdNetwork { + GOOGLE_AD_MANAGER = 'GOOGLE_AD_MANAGER', + ADMOB = 'ADMOB', + AD_GENERATION = 'AD_GENERATION', + IRON_SOURCE = 'IRON_SOURCE', + MAX = 'MAX', + NIMBUS = 'NIMBUS', + OTHER = 'OTHER', +}; -/** - * @internal - */ export function isAdNetwork(value: any): value is AdNetwork { return Object.values(AdNetwork).includes(value); } diff --git a/src/types/AdNetworkInfo.ts b/src/types/AdNetworkInfo.ts index a04137c..eabe1ac 100644 --- a/src/types/AdNetworkInfo.ts +++ b/src/types/AdNetworkInfo.ts @@ -18,9 +18,6 @@ import { AdNetwork, isAdNetwork } from './AdNetwork'; -/** - * @public - */ export interface AdNetworkInfo { /** * The name of the primary ad server or mediator @@ -29,9 +26,6 @@ export interface AdNetworkInfo { adNetworkProperties?: { [key: string]: string }; } -/** - * @internal - */ export function validateAdNetworkInfo(adNetworkInfo: AdNetworkInfo) { if (typeof adNetworkInfo !== 'object') { throw new Error("'adNetworkInfo' expected an object value"); diff --git a/src/types/AdType.ts b/src/types/AdType.ts index 5a5357e..1e960db 100644 --- a/src/types/AdType.ts +++ b/src/types/AdType.ts @@ -16,22 +16,11 @@ * along with Foobar. If not, see . */ -/** - * @public - */ -export const AdType = { - BANNER: 'banner', - INTERSTITIAL: 'interstitial', -} as const; - -/** - * @public - */ -export type AdType = typeof AdType[keyof typeof AdType]; +export enum AdType { + BANNER = 'banner', + INTERSTITIAL = 'interstitial', +} -/** - * @internal - */ export function isAdType(value: any): value is AdType { return Object.values(AdType).includes(value); } diff --git a/src/types/MRAIDPolicy.ts b/src/types/MRAIDPolicy.ts index ffcc197..04fcfe1 100644 --- a/src/types/MRAIDPolicy.ts +++ b/src/types/MRAIDPolicy.ts @@ -16,23 +16,12 @@ * along with Foobar. If not, see . */ -/** - * @public - */ -export const MRAIDPolicy = { - NONE: 'NONE', - DFP: 'DFP', - CUSTOM: 'CUSTOM', -} as const; - -/** - * @public - */ -export type MRAIDPolicy = typeof MRAIDPolicy[keyof typeof MRAIDPolicy]; +export enum MRAIDPolicy { + NONE = 'NONE', + DFP = 'DFP', + CUSTOM = 'CUSTOM', +}; -/** - * @internal - */ export function isMRAIDPolicy(value: any): value is MRAIDPolicy { return Object.values(MRAIDPolicy).includes(value); }