Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AdEvent enum to have an exhaustive list of all possible AdEvent values #3374

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

avencat
Copy link
Contributor

@avencat avencat commented Nov 22, 2023

To test this PR, you have to enable ads in your project, see:
https://react-native-video.github.io/react-native-video/component/props#adtagurl (it appears the link needs to be fixed too) and iOS and Android parts of https://react-native-video.github.io/react-native-video/installation

  • On iOS, add this to your Podfile:
$RNVideoUseGoogleIMA = true
  • On Android, add this to buildScript.ext section of your android/build.gradle file:
        RNVUseExoplayerIMA = true

Then, you should be able to do:

import { AdEvent } from 'react-native-video'

const MyComponent = () => {
  const onReceiveAdEvent = (adEvent: AdEvent) => {
    if (adEvent === AdEvent.COMPLETED) {
      console.log('Ad completed!');
    } else {
      console.log(adEvent);
    }
  };

  return (
    <Video
      adTagUrl='https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostoptimizedpodbumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='
      onReceiveAdEvent={onReceiveAdEvent}
    />
  );
};

Copy link
Collaborator

@freeboub freeboub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you !
Can you just confirm I shall merge #3373 before ?

@avencat
Copy link
Contributor Author

avencat commented Nov 22, 2023

@freeboub yes exactly, because otherwise the types won't be accurate for iOS! 😕

Copy link
Collaborator

@KrzysztofMoch KrzysztofMoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @avencat 🚀

@freeboub freeboub merged commit b3744f9 into TheWidlarzGroup:master Nov 23, 2023
1 check passed
@avencat avencat deleted the feat/ad-event-enum branch November 23, 2023 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants