项目作者: Tw1ddle

项目描述 :
:money_with_wings: Unofficial AdMob ads support for Haxe/OpenFL Android and iOS targets.
高级语言: Objective-C
项目地址: git://github.com/Tw1ddle/samcodes-admob.git
创建时间: 2015-02-01T20:45:19Z
项目社区:https://github.com/Tw1ddle/samcodes-admob

开源协议:MIT License

下载


Haxe AdMob

License

Unofficial AdMob banner and interstitial ad support for iOS and Android Haxe OpenFL targets.

This is deprecated - I am no longer updating it because I do not currently use AdMob for any projects. Feel free to fork this and bring it up to date though!

Features

Supports:

  • Caching, showing and dismissing interstitial ads.
  • Showing, hiding and refreshing banner ads.
  • Customizable listener for reacting to SDK events.
  • Customizable banner positioning.
  • Multiple ad units.

Doesn’t support:

  • Displaying more than one banner ad at a time.
  • IAP functionality.
  • Rewarded videos.
  • DoubleClick ads or mediation.

Install

  1. haxelib install samcodes-admob

Usage

Include the haxelib through Project.xml:

  1. <haxelib name="samcodes-admob" ></haxelib>

For Android enter a device id if you want to use test ads on one:

  1. <!-- Set this if you want to use test ads on a particular device. -->
  2. <setenv name="AdmobTestDeviceId" value="YOUR_HASHED_TEST_DEVICE_ID" ></setenv>

For iOS you can specify a test device id in the AdMob.initAdMob() call in Haxe code:

  1. AdMob.initAdMob("YOUR_HASHED_TEST_DEVICE_ID");
  1. import extension.admob.AdMob;
  2. import extension.admob.AdMobListener;
  3. import extension.admob.AdMobGravity;
  4. #if ios
  5. AdMob.initAdMob("YOUR_HASHED_TEST_DEVICE_ID"); // Specify a test device id for iOS here.
  6. #end
  7. // Optionally subclass AdMobListener and set it here to handle SDK events.
  8. // Extending and customizing this is useful for actions like pausing the game when showing interstitials, showing banners as soon as they cache etc.
  9. AdMob.setListener(new AdMobListener());
  10. var interstitialId:String = "my_interstitial_id";
  11. AdMob.cacheInterstitial(interstitialId); // Cache interstitial with the id from your AdMob dashboard.
  12. // Later...
  13. if(AdMob.hasInterstitial(interstitialId) {
  14. // Shows an interstitial with the given id.
  15. // If this is called and the interstitial isn't cached, then it won't display at all - that's just how the AdMob SDK works.
  16. // You should cache interstitial ads well in advance of showing them.
  17. AdMob.showInterstitial(interstitialId);
  18. }
  19. AdMob.setBannerPosition(AdMobHorizontalGravity.CENTER, AdMobVerticalGravity.BOTTOM); // All banners will appear bottom center of the screen
  20. var bannerId:String = "my_banner_id";
  21. AdMob.refreshBanner(bannerId);
  22. // Later...
  23. AdMob.showBanner(bannerId); // Shows the banner (it will only show if the SDK has finished caching a banner after calling refreshBanner)
  24. AdMob.hideBanner(bannerId); // Hides the banner

Notes

Use #if (android || ios) conditionals around your imports and calls to this library for cross platform projects, as there is no stub/fallback implementation included in the haxelib.

If you need to rebuild the iOS or simulator ndlls navigate to /project and run rebuild_ndlls.sh.