GithubHelp home page GithubHelp logo

aoneapps1 / extension-admob Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haxeextension/extension-admob

0.0 1.0 0.0 52.81 MB

OpenFL extension for "Google AdMob" on iOS and Android.

License: Other

Shell 0.30% Haxe 5.03% Objective-C 86.77% C++ 1.80% Objective-C++ 5.20% C 0.90%

extension-admob's Introduction

#extension-admob

OpenFL extension for "Google AdMob" on iOS and Android. This extension allows you to easily integrate Google AdMob on your OpenFL (or HaxeFlixel) game / application.

###Main Features

  • Banners & Interstitial Support.
  • Setup your banners to be on top or on the bottom of the screen.
  • Allows you to specify min amount of time between interstitial displays (to avoid annoying your users).
  • Allows you to specify min amount of calls to interstitial before it actually gets displayed (to avoid annoying your users).
  • Callback support for Interstitial Events.

###Simple use Example

// This example show a simple use case.

import extension.admob.AdMob;
import extension.admob.GravityMode;

class MainClass {

	function new() {
		// first of all, decide if you want to display testing ads by calling enableTestingAds() method.
		// Note that if you decide to call enableTestingAds(), you must do that before calling INIT methods.
		AdMob.enableTestingAds();

		// if your app is for children and you want to enable the COPPA policy,
		// you need to call tagForChildDirectedTreatment(), before calling INIT.
		// AdMob.tagForChildDirectedTreatment();

		// If you want to get instertitial events (LOADING, LOADED, CLOSED, DISPLAYING, ETC), provide
		// some callback function for this.
		AdMob.onInterstitialEvent = onInterstitialEvent;
		
		// then call init with Android and iOS banner IDs in the main method.
		// parameters are (bannerId:String, interstitialId:String, gravityMode:GravityMode).
		// if you don't have the bannerId and interstitialId, go to www.google.com/ads/admob to create them.

		AdMob.initAndroid("ca-app-pub-XXXXX123456","ca-app-pub-XXXXX123457", GravityMode.BOTTOM); // may also be GravityMode.TOP
		AdMob.initIOS("ca-app-pub-XXXXX123458","ca-app-pub-XXXXX123459", GravityMode.BOTTOM); // may also be GravityMode.TOP

		// NOTE: If your game allows screen rotation, you should call AdMob.onResize(); when rotation happens.
	}
	
	function gameOver() {
		// some implementation
		AdMob.showInterstitial(0);

		/* NOTE:
		showInterstitial function has two parameters you can use to control how often you want to display the interstitial ad.

		public static function showInterstitial(minInterval:Int=60, minCallsBeforeDisplay:Int=0);

		* The banner will not show if it was displayed less than "minInterval" seconds ago.
		* The banner will show only after "#minCallsBeforeDisplay" calls to showInterstitial function.

		- To display an interstitial after every time the game finishes, call:
		AdMob.showInterstitial(0);
		- To avoid displaying the interstitial if the game was too short (60 seconds), call:
		AdMob.showInterstitial(60);
		- To display an interstitial every 3 finished games call:
		AdMob.showInterstitial(0,3);
		- To display an interstitial every 3 finished games (but never before 120 secs since last display), call:
		AdMob.showInterstitial(120,3); */
	}
	
	function mainMenu() {
		// some implementation
		AdMob.showBanner(); // this will show the AdMob banner.
	}

	function beginGame() {
		// some implementation
		AdMob.hideBanner(); // if you don't want the banner to be on screen while playing... call AdMob.hideBanner();
	}
	
	function onInterstitialEvent(event:String) {
		trace("THE INSTERSTITIAL IS "+event);
		/*
		Note that the "event" String will be one of this:
		    AdMob.LEAVING
		    AdMob.FAILED
		    AdMob.CLOSED
		    AdMob.DISPLAYING
		    AdMob.LOADED
		    AdMob.LOADING
		
		So, you can do something like:
		if(event == AdMob.CLOSED) trace("The player dismissed the ad!");
		else if(event == AdMob.LEAVING) trace("The player clicked the ad :), and we're leaving to the ad destination");
		else if(event == AdMob.FAILED) trace("Failed to load the ad... the extension will retry automatically.");
		*/
	}
	
}

###How to Install

To install this library, you can simply get the library from haxelib like this:

haxelib install extension-admob

Once this is done, you just need to add this to your project.xml

<haxelib name="extension-admob" />

Also, you may need to set android sdk version to 23 or higher (as some versions of google play services requires that):

<android target-sdk-version="23" if="android" />

###Disclaimer

Google is a registered trademark of Google Inc. http://unibrander.com/united-states/140279US/google.html

AdMob is a registrered trademark of Google Inc. http://unibrander.com/united-states/479956US/admob.html

###License

The MIT License (MIT) - LICENSE.md

Copyright © 2013 SempaiGames (http://www.sempaigames.com)

Author: Federico Bricker

extension-admob's People

Contributors

fbricker avatar jgranick avatar 01010111 avatar

Watchers

James Cloos 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.