setupad-prebid-react-native 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/VeonPrebidReactNativeViewComponentView.mm +27 -0
- package/lib/module/VeonPrebidAd.js +30 -33
- package/lib/module/VeonPrebidAd.js.map +1 -1
- package/lib/module/VeonPrebidReactNativeViewNativeComponent.ts +30 -1
- package/lib/typescript/src/VeonPrebidAd.d.ts.map +1 -1
- package/lib/typescript/src/VeonPrebidReactNativeViewNativeComponent.d.ts +14 -1
- package/lib/typescript/src/VeonPrebidReactNativeViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/VeonPrebidAd.tsx +29 -48
- package/src/VeonPrebidReactNativeViewNativeComponent.ts +30 -1
|
@@ -77,6 +77,33 @@ using namespace facebook::react;
|
|
|
77
77
|
[super updateProps:props oldProps:oldProps];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
81
|
+
{
|
|
82
|
+
NSLog(@"VeonPrebid iOS: handleCommand: %@", commandName);
|
|
83
|
+
|
|
84
|
+
if ([commandName isEqualToString:@"loadBanner"]) {
|
|
85
|
+
[_view performSelector:@selector(loadBanner)];
|
|
86
|
+
} else if ([commandName isEqualToString:@"showBanner"]) {
|
|
87
|
+
[_view performSelector:@selector(showBanner)];
|
|
88
|
+
} else if ([commandName isEqualToString:@"hideBanner"]) {
|
|
89
|
+
[_view performSelector:@selector(hideBanner)];
|
|
90
|
+
} else if ([commandName isEqualToString:@"loadInterstitial"]) {
|
|
91
|
+
[_view performSelector:@selector(loadInterstitial)];
|
|
92
|
+
} else if ([commandName isEqualToString:@"showInterstitial"]) {
|
|
93
|
+
[_view performSelector:@selector(showInterstitial)];
|
|
94
|
+
} else if ([commandName isEqualToString:@"hideInterstitial"]) {
|
|
95
|
+
[_view performSelector:@selector(hideInterstitial)];
|
|
96
|
+
} else if ([commandName isEqualToString:@"pauseAuction"]) {
|
|
97
|
+
[_view performSelector:@selector(pauseAuction)];
|
|
98
|
+
} else if ([commandName isEqualToString:@"resumeAuction"]) {
|
|
99
|
+
[_view performSelector:@selector(resumeAuction)];
|
|
100
|
+
} else if ([commandName isEqualToString:@"destroyAuction"]) {
|
|
101
|
+
[_view performSelector:@selector(destroyAuction)];
|
|
102
|
+
} else {
|
|
103
|
+
[super handleCommand:commandName args:args];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
- (void)updateEventEmitter:(EventEmitter::Shared const &)eventEmitter
|
|
81
108
|
{
|
|
82
109
|
[super updateEventEmitter:eventEmitter];
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useRef, useImperativeHandle, forwardRef, useCallback } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import VeonPrebidReactNativeView from './VeonPrebidReactNativeViewNativeComponent';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import VeonPrebidReactNativeView, { Commands } from './VeonPrebidReactNativeViewNativeComponent';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
// Command IDs - must match ViewManager (starts from 0 in iOS Old Architecture!)
|
|
8
|
-
const Commands = {
|
|
9
|
-
loadBanner: 0,
|
|
10
|
-
showBanner: 1,
|
|
11
|
-
hideBanner: 2,
|
|
12
|
-
loadInterstitial: 3,
|
|
13
|
-
showInterstitial: 4,
|
|
14
|
-
hideInterstitial: 5,
|
|
15
|
-
pauseAuction: 6,
|
|
16
|
-
resumeAuction: 7,
|
|
17
|
-
destroyAuction: 8
|
|
18
|
-
};
|
|
19
7
|
const VeonPrebidAd = /*#__PURE__*/forwardRef((props, ref) => {
|
|
20
8
|
const {
|
|
21
9
|
adType,
|
|
@@ -32,26 +20,35 @@ const VeonPrebidAd = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
32
20
|
style
|
|
33
21
|
} = props;
|
|
34
22
|
const viewRef = useRef(null);
|
|
35
|
-
const executeCommand = useCallback((commandName, commandId) => {
|
|
36
|
-
const node = findNodeHandle(viewRef.current);
|
|
37
|
-
if (!node) {
|
|
38
|
-
console.warn(`Cannot execute ${commandName} - view not mounted`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
console.log(`Executing ${commandName} (ID: ${commandId}) on node: ${node}`);
|
|
42
|
-
UIManager.dispatchViewManagerCommand(node, commandId, []);
|
|
43
|
-
}, []);
|
|
44
23
|
useImperativeHandle(ref, () => ({
|
|
45
|
-
loadBanner: () =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
loadBanner: () => {
|
|
25
|
+
if (viewRef.current) Commands.loadBanner(viewRef.current);
|
|
26
|
+
},
|
|
27
|
+
showBanner: () => {
|
|
28
|
+
if (viewRef.current) Commands.showBanner(viewRef.current);
|
|
29
|
+
},
|
|
30
|
+
hideBanner: () => {
|
|
31
|
+
if (viewRef.current) Commands.hideBanner(viewRef.current);
|
|
32
|
+
},
|
|
33
|
+
loadInterstitial: () => {
|
|
34
|
+
if (viewRef.current) Commands.loadInterstitial(viewRef.current);
|
|
35
|
+
},
|
|
36
|
+
showInterstitial: () => {
|
|
37
|
+
if (viewRef.current) Commands.showInterstitial(viewRef.current);
|
|
38
|
+
},
|
|
39
|
+
hideInterstitial: () => {
|
|
40
|
+
if (viewRef.current) Commands.hideInterstitial(viewRef.current);
|
|
41
|
+
},
|
|
42
|
+
pauseAuction: () => {
|
|
43
|
+
if (viewRef.current) Commands.pauseAuction(viewRef.current);
|
|
44
|
+
},
|
|
45
|
+
resumeAuction: () => {
|
|
46
|
+
if (viewRef.current) Commands.resumeAuction(viewRef.current);
|
|
47
|
+
},
|
|
48
|
+
destroyAuction: () => {
|
|
49
|
+
if (viewRef.current) Commands.destroyAuction(viewRef.current);
|
|
50
|
+
}
|
|
51
|
+
}), []);
|
|
55
52
|
const handleAdLoaded = useCallback(event => {
|
|
56
53
|
const data = event.nativeEvent;
|
|
57
54
|
console.log('Ad loaded:', data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useImperativeHandle","forwardRef","useCallback","
|
|
1
|
+
{"version":3,"names":["useRef","useImperativeHandle","forwardRef","useCallback","StyleSheet","View","VeonPrebidReactNativeView","Commands","jsx","_jsx","VeonPrebidAd","props","ref","adType","configId","adUnitId","width","height","refreshInterval","onAdLoaded","onAdDisplayed","onAdFailed","onAdClicked","onAdClosed","style","viewRef","loadBanner","current","showBanner","hideBanner","loadInterstitial","showInterstitial","hideInterstitial","pauseAuction","resumeAuction","destroyAuction","handleAdLoaded","event","data","nativeEvent","console","log","handleAdDisplayed","handleAdFailed","error","sdkType","handleAdClicked","handleAdClosed","containerStyle","overflow","children","absoluteFill","displayName"],"sourceRoot":"../../src","sources":["VeonPrebidAd.tsx"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,mBAAmB,EAAEC,UAAU,EAAEC,WAAW,QAAQ,OAAO;AAC5E,SACEC,UAAU,EACVC,IAAI,QAEC,cAAc;AACrB,OAAOC,yBAAyB,IAAIC,QAAQ,QAAQ,4CAA4C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGjG,MAAMC,YAAY,gBAAGR,UAAU,CAC7B,CAACS,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;IACJC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,KAAK;IACLC,MAAM;IACNC,eAAe,GAAG,EAAE;IACpBC,UAAU;IACVC,aAAa;IACbC,UAAU;IACVC,WAAW;IACXC,UAAU;IACVC;EACF,CAAC,GAAGb,KAAK;EAET,MAAMc,OAAO,GAAGzB,MAAM,CAAM,IAAI,CAAC;EAEjCC,mBAAmB,CACjBW,GAAG,EACH,OAAO;IACLc,UAAU,EAAEA,CAAA,KAAM;MAChB,IAAID,OAA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,EAAE,QAAQ;IAClB,IAAIpC,MAAM,KAAK,QAAQ,IAAIG,KAAK,IAAIC,MAAM,GACtC;MAAED,KAAK;MAAEC;IAAO,CAAC,GACjB;MAAED,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC,CAAC;IAC5B,IAAIO,KAAK,IAAI,CAAC,CAAC;EACjB,CAAC;EAED,oBACEf,IAAA,CAACJ,IAAI;IAACmB,KAAK,EAAEwB,cAAe;IAAAE,QAAA,eAC1BzC,IAAA,CAACH,yBAAyB;MACxBM,GAAG,EAAEa,OAAQ;MACbD,KAAK,EAAEpB,UAAU,CAAC+C,YAAa;MAC/BtC,MAAM,EAAEA,MAAO;MACfC,QAAQ,EAAEA,QAAS;MACnBC,QAAQ,EAAEA,QAAS;MACnBC,KAAK,EAAEA,KAAgB;MACvBC,MAAM,EAAEA,MAAiB;MACzBC,eAAe,EAAEA,eAA0B;MAC3CC,UAAU,EAAEiB,cAAe;MAC3BhB,aAAa,EAAEsB,iBAAkB;MACjCrB,UAAU,EAAEsB,cAAe;MAC3BrB,WAAW,EAAEwB,eAAgB;MAC7BvB,UAAU,EAAEwB;IAAe,CAC5B;EAAC,CACE,CAAC;AAEX,CACF,CAAC;AAEDrC,YAAY,CAAC0C,WAAW,GAAG,cAAc;AAEzC,eAAe1C,YAAY","ignoreList":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
2
|
import type {
|
|
3
3
|
Int32,
|
|
4
4
|
DirectEventHandler,
|
|
5
5
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
6
|
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
7
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Event payload for ad events
|
|
@@ -44,6 +45,34 @@ export interface NativeProps extends ViewProps {
|
|
|
44
45
|
onAdClosed?: DirectEventHandler<AdEventPayload>;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
49
|
+
|
|
50
|
+
export interface NativeCommands {
|
|
51
|
+
loadBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
52
|
+
showBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
53
|
+
hideBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
54
|
+
loadInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
55
|
+
showInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
56
|
+
hideInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
57
|
+
pauseAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
58
|
+
resumeAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
59
|
+
destroyAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
63
|
+
supportedCommands: [
|
|
64
|
+
'loadBanner',
|
|
65
|
+
'showBanner',
|
|
66
|
+
'hideBanner',
|
|
67
|
+
'loadInterstitial',
|
|
68
|
+
'showInterstitial',
|
|
69
|
+
'hideInterstitial',
|
|
70
|
+
'pauseAuction',
|
|
71
|
+
'resumeAuction',
|
|
72
|
+
'destroyAuction',
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
|
|
47
76
|
/**
|
|
48
77
|
* Native component for Veon Prebid ads
|
|
49
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VeonPrebidAd.d.ts","sourceRoot":"","sources":["../../../src/VeonPrebidAd.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VeonPrebidAd.d.ts","sourceRoot":"","sources":["../../../src/VeonPrebidAd.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAe,MAAM,SAAS,CAAC;AAE5E,QAAA,MAAM,YAAY,4GA8HjB,CAAC;AAIF,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
2
|
import type { Int32, DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
3
|
/**
|
|
4
4
|
* Event payload for ad events
|
|
@@ -30,6 +30,19 @@ export interface NativeProps extends ViewProps {
|
|
|
30
30
|
onAdClicked?: DirectEventHandler<AdEventPayload>;
|
|
31
31
|
onAdClosed?: DirectEventHandler<AdEventPayload>;
|
|
32
32
|
}
|
|
33
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
34
|
+
export interface NativeCommands {
|
|
35
|
+
loadBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
36
|
+
showBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
37
|
+
hideBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
38
|
+
loadInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
39
|
+
showInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
40
|
+
hideInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
41
|
+
pauseAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
42
|
+
resumeAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
43
|
+
destroyAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
44
|
+
}
|
|
45
|
+
export declare const Commands: NativeCommands;
|
|
33
46
|
/**
|
|
34
47
|
* Native component for Veon Prebid ads
|
|
35
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VeonPrebidReactNativeViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/VeonPrebidReactNativeViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"VeonPrebidReactNativeViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/VeonPrebidReactNativeViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,KAAK,EACL,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAInD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,sCAAsC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,uCAAuC;IACvC,MAAM,CAAC,EAAE,KAAK,CAAC;IAEf,6DAA6D;IAC7D,eAAe,CAAC,EAAE,KAAK,CAAC;IAGxB,UAAU,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAChD,WAAW,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,KAAK,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC/D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC/D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACrE,YAAY,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACjE,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAClE,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACpE;AAED,eAAO,MAAM,QAAQ,EAAE,cAYrB,CAAC;AAEH;;GAEG;;;;AACH,wBAAgF"}
|
package/package.json
CHANGED
package/src/VeonPrebidAd.tsx
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import { useRef, useImperativeHandle, forwardRef, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
UIManager,
|
|
4
|
-
findNodeHandle,
|
|
5
3
|
StyleSheet,
|
|
6
4
|
View,
|
|
7
5
|
type ViewStyle,
|
|
8
6
|
} from 'react-native';
|
|
9
|
-
import VeonPrebidReactNativeView from './VeonPrebidReactNativeViewNativeComponent';
|
|
7
|
+
import VeonPrebidReactNativeView, { Commands } from './VeonPrebidReactNativeViewNativeComponent';
|
|
10
8
|
import type { VeonPrebidAdProps, AdController, AdEventData } from './types';
|
|
11
9
|
|
|
12
|
-
// Command IDs - must match ViewManager (starts from 0 in iOS Old Architecture!)
|
|
13
|
-
const Commands = {
|
|
14
|
-
loadBanner: 0,
|
|
15
|
-
showBanner: 1,
|
|
16
|
-
hideBanner: 2,
|
|
17
|
-
loadInterstitial: 3,
|
|
18
|
-
showInterstitial: 4,
|
|
19
|
-
hideInterstitial: 5,
|
|
20
|
-
pauseAuction: 6,
|
|
21
|
-
resumeAuction: 7,
|
|
22
|
-
destroyAuction: 8,
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
10
|
const VeonPrebidAd = forwardRef<AdController, VeonPrebidAdProps>(
|
|
26
11
|
(props, ref) => {
|
|
27
12
|
const {
|
|
@@ -41,42 +26,38 @@ const VeonPrebidAd = forwardRef<AdController, VeonPrebidAdProps>(
|
|
|
41
26
|
|
|
42
27
|
const viewRef = useRef<any>(null);
|
|
43
28
|
|
|
44
|
-
const executeCommand = useCallback(
|
|
45
|
-
(commandName: string, commandId: number) => {
|
|
46
|
-
const node = findNodeHandle(viewRef.current);
|
|
47
|
-
if (!node) {
|
|
48
|
-
console.warn(`Cannot execute ${commandName} - view not mounted`);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log(
|
|
53
|
-
`Executing ${commandName} (ID: ${commandId}) on node: ${node}`
|
|
54
|
-
);
|
|
55
|
-
UIManager.dispatchViewManagerCommand(node, commandId, []);
|
|
56
|
-
},
|
|
57
|
-
[]
|
|
58
|
-
);
|
|
59
|
-
|
|
60
29
|
useImperativeHandle(
|
|
61
30
|
ref,
|
|
62
31
|
() => ({
|
|
63
|
-
loadBanner: () =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
loadBanner: () => {
|
|
33
|
+
if (viewRef.current) Commands.loadBanner(viewRef.current);
|
|
34
|
+
},
|
|
35
|
+
showBanner: () => {
|
|
36
|
+
if (viewRef.current) Commands.showBanner(viewRef.current);
|
|
37
|
+
},
|
|
38
|
+
hideBanner: () => {
|
|
39
|
+
if (viewRef.current) Commands.hideBanner(viewRef.current);
|
|
40
|
+
},
|
|
41
|
+
loadInterstitial: () => {
|
|
42
|
+
if (viewRef.current) Commands.loadInterstitial(viewRef.current);
|
|
43
|
+
},
|
|
44
|
+
showInterstitial: () => {
|
|
45
|
+
if (viewRef.current) Commands.showInterstitial(viewRef.current);
|
|
46
|
+
},
|
|
47
|
+
hideInterstitial: () => {
|
|
48
|
+
if (viewRef.current) Commands.hideInterstitial(viewRef.current);
|
|
49
|
+
},
|
|
50
|
+
pauseAuction: () => {
|
|
51
|
+
if (viewRef.current) Commands.pauseAuction(viewRef.current);
|
|
52
|
+
},
|
|
53
|
+
resumeAuction: () => {
|
|
54
|
+
if (viewRef.current) Commands.resumeAuction(viewRef.current);
|
|
55
|
+
},
|
|
56
|
+
destroyAuction: () => {
|
|
57
|
+
if (viewRef.current) Commands.destroyAuction(viewRef.current);
|
|
58
|
+
},
|
|
78
59
|
}),
|
|
79
|
-
[
|
|
60
|
+
[]
|
|
80
61
|
);
|
|
81
62
|
|
|
82
63
|
const handleAdLoaded = useCallback(
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
2
|
import type {
|
|
3
3
|
Int32,
|
|
4
4
|
DirectEventHandler,
|
|
5
5
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
6
|
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
7
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Event payload for ad events
|
|
@@ -44,6 +45,34 @@ export interface NativeProps extends ViewProps {
|
|
|
44
45
|
onAdClosed?: DirectEventHandler<AdEventPayload>;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
49
|
+
|
|
50
|
+
export interface NativeCommands {
|
|
51
|
+
loadBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
52
|
+
showBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
53
|
+
hideBanner: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
54
|
+
loadInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
55
|
+
showInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
56
|
+
hideInterstitial: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
57
|
+
pauseAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
58
|
+
resumeAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
59
|
+
destroyAuction: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
63
|
+
supportedCommands: [
|
|
64
|
+
'loadBanner',
|
|
65
|
+
'showBanner',
|
|
66
|
+
'hideBanner',
|
|
67
|
+
'loadInterstitial',
|
|
68
|
+
'showInterstitial',
|
|
69
|
+
'hideInterstitial',
|
|
70
|
+
'pauseAuction',
|
|
71
|
+
'resumeAuction',
|
|
72
|
+
'destroyAuction',
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
|
|
47
76
|
/**
|
|
48
77
|
* Native component for Veon Prebid ads
|
|
49
78
|
*/
|