-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNMobvistaRewardVideo.js
125 lines (109 loc) · 3.24 KB
/
RNMobvistaRewardVideo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import React, { Component } from 'react';
import {
requireNativeComponent,
UIManager,
findNodeHandle,
ViewPropTypes,
NativeModules,
TouchableOpacity
} from 'react-native';
const RNRewardVideo = requireNativeComponent('RNRewardVideo', RewardVideo, {});
const RNRewardVideoManager = NativeModules.RNRewardVideoManager;
/**
* Example:
<Touchable
style={ {width: "100%", flex: 1} }
onPress={ () => {
this._basicExample.showRewardVideo();
} }
>
<RewardVideo
ref={ el => (this._basicExample = el) }
onVideoAdLoadSuccess={ event => {
console.log(event);
} }
onVideoAdLoadFailed={ event => {
console.log(event);
} }
onVideoAdShowSuccess={ event => {
console.log(event);
} }
onVideoAdShowFailed={ event => {
console.log(event);
} }
onVideoAdDismissed={ event => {
console.log(event);
} }
onVideoAdClicked={ event => {
console.log(event);
} }
/>
</Touchable>
*/
export default class RewardVideo extends Component {
constructor() {
super();
}
componentDidMount() {
// this.loadBanner();
}
loadBanner() {
console.log("loadBanner RNRewardVideo");
}
showRewardVideo() {
console.log("showRewardVideo");
RNRewardVideoManager.showRewardVideo();
}
handleOnVideoAdLoadSuccess = (event) => {
if (this.props.onVideoAdLoadSuccess) {
const { unitId } = event.nativeEvent;
this.props.onVideoAdLoadSuccess({ unitId });
}
};
handleOnVideoAdLoadFailed = (event) => {
if (this.props.onVideoAdLoadFailed) {
const {unitId, error} = event.nativeEvent;
this.props.onVideoAdLoadFailed({unitId, error});
}
};
handleOnVideoAdShowSuccess = (event) => {
if (this.props.onVideoAdShowSuccess) {
const {unitId} = event.nativeEvent;
this.props.onVideoAdShowSuccess({unitId});
}
};
handleOnVideoAdShowFailed = (event) => {
if (this.props.onVideoAdShowFailed) {
const {unitId, error} = event.nativeEvent;
this.props.onVideoAdShowFailed({unitId, error});
}
};
handleOnVideoAdDismissed = (event) => {
if (this.props.onVideoAdDismissed) {
const {unitId, rewardName, rewardAmount} = event.nativeEvent;
this.props.onVideoAdDismissed({unitId, rewardName, rewardAmount});
}
};
handleOnVideoAdClicked = (event) => {
if (this.props.onVideoAdClicked) {
const {unitId} = event.nativeEvent;
this.props.onVideoAdClicked({unitId});
}
};
render() {
return (
<TouchableOpacity style={{...this.props.style}} onPress={() => {this.showRewardVideo()}}>
<RNRewardVideo
{ ...this.props }
ref={ el => (this._bannerView = el) }
onVideoAdLoadSuccess={ this.handleOnVideoAdLoadSuccess }
onVideoAdLoadFailed={ this.handleOnVideoAdLoadFailed }
onVideoAdShowSuccess={ this.handleOnVideoAdShowSuccess }
onVideoAdShowFailed={ this.handleOnVideoAdShowFailed }
onVideoAdDismissed={ this.handleOnVideoAdDismissed }
onVideoAdClicked={ this.handleOnVideoAdClicked }
/>
</TouchableOpacity>
)
}
}