Code Monkey home page Code Monkey logo

flutter_unity_ads's Introduction

unity_ads_plugin

Pub

Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.

Getting Started

1. Initialization:

    UnityAds.init(
      gameId: 'game_id',
      listener: (state, args) => print('Init Listener: $state => $args'),
    );

Set your Game id. For testing purposes set testMode to true.


Android only: To change ads behavior in Firebase Test Lab use firebaseTestLabMode parameter. Possible values:

Mode Description
disableAds Ads are not displayed in the Firebase Test Lab (by default)
showAdsInTestMode Ads are displayed in test mode.
showAds Real ads are displayed, if testMode is false.

2. Show Rewarded/Interstitial Video Ad:

Rewarded Video Ad Interstitial Video Ad

UnityAds.showVideoAd(
  placementId: 'video_placement_id',
  listener: (state, args) {
    if (state == UnityAdState.complete) {
      print('User watched a video. User should get a reward!');
    } else if (state == UnityAdState.skipped) {
      print('User cancel video.');
    }
  },
);

Check if the video ad is ready:

UnityAds.isReady(placementId: 'video_placement_id');

Possible unity ad state:

State Description
ready Ad loaded successfully.
error Some error occurred.
started Video ad started.
complete Video played till the end. Use it to reward the user.
skipped Video ad closed.

Server-to-server redeem callbacks

UnityAds.showVideoAd has serverId parameter.

To use server-to-server callbacks, you need to set this parameter.

Read more on unity3d.com.

3. Show Banner Ad:

Banner Ad

Place UnityBannerAd widget in your app.

UnityBannerAd(
  placementId: "banner_placement_id",
  listener: (state, args) {
    print('Banner Listener: $state => $args');
  },
)

Possible unity banner ad state:

State Description
loaded Banner is loaded.
clicked Banner is clicked.
error Error during loading banner.

flutter_unity_ads's People

Contributors

pavelzaichyk avatar venkata-reddy-dev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.