Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5ad458f
fix codegenConfig
oromis300 Oct 28, 2024
9f25d85
upgrade version
oromis300 Oct 28, 2024
42496f8
try change adtype
oromis300 Oct 28, 2024
53e5b87
add type inside module file
oromis300 Oct 29, 2024
bc9adb0
upgrade version
oromis300 Oct 29, 2024
c0b6c8d
try fix wrong type
oromis300 Oct 29, 2024
329b545
try fix wrong type
oromis300 Oct 29, 2024
ae762d6
add type inside module file
oromis300 Oct 29, 2024
87a9b11
add type inside module file
oromis300 Oct 29, 2024
2cecf85
add type inside module file
oromis300 Oct 29, 2024
c9727e3
add type inside module file
oromis300 Oct 29, 2024
bdd8293
add type inside module file
oromis300 Oct 29, 2024
0c42add
add type inside module file
oromis300 Oct 29, 2024
863ed68
add type inside module file
oromis300 Oct 29, 2024
9a332b5
add type inside module file
oromis300 Oct 29, 2024
6103478
add type inside module file
oromis300 Oct 29, 2024
c29d9e1
remove annotations
oromis300 Oct 29, 2024
4f01a56
remove annotations
oromis300 Oct 29, 2024
9f037a9
remove annotations
oromis300 Oct 29, 2024
8f4cf7d
try remove TSIndexedAccessType
oromis300 Oct 29, 2024
4f2d1bf
transform adType to enum
oromis300 Oct 29, 2024
34903d2
transform adNetwork to enum
oromis300 Oct 29, 2024
3f2f5b8
transform MRAIDPolicy to enum
oromis300 Oct 29, 2024
37cc803
remove enum
oromis300 Oct 29, 2024
2e14304
remove union type
oromis300 Oct 29, 2024
0d8f377
optional size
oromis300 Oct 29, 2024
831f107
remove doubled export
oromis300 Oct 29, 2024
69b9695
change folly version
oromis300 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RNAmazonPublisherServices.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-aps",
"version": "2.0.1",
"version": "2.0.3",
"author": "AdversportTeam <rm@adversport.com> (https://github.com/AdversportTeam)",
"contributors": [
"Jay Kim <me@wjay.kim> (https://github.com/wjaykim)"
Expand Down Expand Up @@ -257,12 +257,8 @@
]
},
"codegenConfig": {
"libraries": [
{
"name": "rnaps",
"type": "modules",
"jsSrcsDir": "./src/turbomodules"
}
]
"name": "rnaps",
"type": "modules",
"jsSrcsDir": "./src/turbomodules"
}
}
28 changes: 0 additions & 28 deletions src/APSAds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
if (typeof appKey !== 'string') {
Expand All @@ -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 {
Expand All @@ -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 (
Expand All @@ -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)) {
Expand All @@ -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') {
Expand All @@ -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') {
Expand All @@ -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') {
Expand All @@ -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') {
Expand Down
11 changes: 0 additions & 11 deletions src/AdError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
23 changes: 1 addition & 22 deletions src/AdLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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<E extends AdLoaderEvent>(
eventName: E,
Expand Down Expand Up @@ -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 {
Expand All @@ -149,18 +133,13 @@ export class AdLoader {
/**
* Stop the auto refresh of the ad.
*
* @public
*/
stopAutoRefresh() {
AdLoader._nativeModule.stopAutoRefresh(this.loaderId);
}

/**
* 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') {
Expand Down
3 changes: 0 additions & 3 deletions src/TestIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

import { Platform } from 'react-native';

/**
* @public
*/
export const TestIds = {
APS_APP_KEY: '',
APS_SLOT_BANNER_320x50: '',
Expand Down
37 changes: 32 additions & 5 deletions src/turbomodules/NativeRNAPSAdLoaderModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,47 @@
* along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/

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;

skadnHelper: (name: string, info?: string) => void;
}

export default TurboModuleRegistry.get<Spec>('RNAPSAdLoaderModule');
export default TurboModuleRegistry.getEnforcing<Spec>('RNAPSAdLoaderModule');
18 changes: 12 additions & 6 deletions src/turbomodules/NativeRNAPSAdsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/

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
Expand All @@ -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;

Expand All @@ -41,4 +47,4 @@ export interface Spec extends TurboModule {
removeCustomAttribute: (key: string) => void;
}

export default TurboModuleRegistry.get<Spec>('RNAPSAdsModule');
export default TurboModuleRegistry.getEnforcing<Spec>('RNAPSAdsModule');
9 changes: 0 additions & 9 deletions src/types/AdLoaderEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@
* along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @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);
}
14 changes: 1 addition & 13 deletions src/types/AdLoaderOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @public
*/
export interface AdLoaderOptions {
/**
* The slotUUID of the ad slot.
Expand All @@ -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`.
Expand All @@ -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");
Expand All @@ -64,9 +55,6 @@ export function validateAdLoaderOptions(adLoaderOptions: AdLoaderOptions) {
}
}

/**
* @internal
*/
export function validateBannerAdLoaderOptions(
adLoaderOptions: BannerAdLoaderOptions
) {
Expand Down
Loading
Loading