Skip to content

Commit

Permalink
feat(ad): add adData to onReceiveAdEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
avencat committed Nov 23, 2023
1 parent b3744f9 commit e8fe11c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,23 @@ public void audioBecomingNoisy() {
receiveEvent(EVENT_AUDIO_BECOMING_NOISY, null);
}

public void receiveAdEvent(String event) {
public void receiveAdEvent(String event, Map<String, String> adData) {
WritableMap map = Arguments.createMap();
map.putString("event", event);

WritableMap adDataMap = Arguments.createMap();
for (Map.Entry<String, String> entry : adData.entrySet()) {
adDataMap.putString(entry.getKey(), entry.getValue());
}
map.putMap("adData", adDataMap);

receiveEvent(EVENT_ON_RECEIVE_AD_EVENT, map);
}

public void receiveAdEvent(String event) {
this.receiveAdEvent(event, Map.of());
}

private void receiveEvent(@VideoEvents String type, WritableMap event) {
eventEmitter.receiveEvent(viewId, type, event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,10 @@ public void setShutterColor(Integer color) {

@Override
public void onAdEvent(AdEvent adEvent) {
eventEmitter.receiveAdEvent(adEvent.getType().name());
if (adEvent.getAdData() != null) {
eventEmitter.receiveAdEvent(adEvent.getType().name(), adEvent.getAdData());
} else {
eventEmitter.receiveAdEvent(adEvent.getType().name());
}
}
}
1 change: 1 addition & 0 deletions ios/Video/Features/RCTIMAAdsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate, I

_video.onReceiveAdEvent?([
"event": type,
"adData": event.adData ?? [String](),
"target": _video.reactTag!
]);
}
Expand Down
1 change: 1 addition & 0 deletions src/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export type OnPictureInPictureStatusChangedData = Readonly<{
}>;

export type OnReceiveAdEventData = Readonly<{
adData: Record<string, string>;
event: AdEvent;
}>;

Expand Down
1 change: 1 addition & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export type OnPictureInPictureStatusChangedData = Readonly<{
}>;

export type OnReceiveAdEventData = Readonly<{
adData: Record<string, string>;
event: AdEvent;
}>;

Expand Down
2 changes: 1 addition & 1 deletion src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export interface ReactVideoProps extends ReactVideoEvents {
source?: ReactVideoSource;
drm?: Drm;
style?: StyleProp<ViewStyle>;
adTagUrl?: string; // iOS
adTagUrl?: string;
audioOnly?: boolean;
automaticallyWaitsToMinimizeStalling?: boolean; // iOS
backBufferDurationMs?: number; // Android
Expand Down

0 comments on commit e8fe11c

Please sign in to comment.