AdMob support for iOS!

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

AdMob support for iOS!

Post by bio1712 » Fri Jul 21, 2017 9:14 pm

AdMob support for iOS!

Here I made a modified version of LÖVE 0.10.2, with a new module:
love.ads!

With this module is possible to request and display ads from LÖVE!
An AdMob account is needed in order to use this module.

I have added 9 functions and 5 callbacks:

love.ads Functions
  • love.ads.createBanner(string adUnitID,string position)
    string adUnitID : Your banner ad unit id.
    string position : The position of the banner. Can be "top" or "bottom".
    Initializes the banner ad without displaying it. This function may be fired only once.
    The banner inizialized is a smart banner.
  • love.ads.showBanner()
    Displays the banner ad. This function may be fired after createBanner
  • love.ads.hideBanner()
    Hides the banner ad. This function may be fired after createBanner
  • love.ads.requestInterstitial(string adUnitID)
    string adUnitID : Your interstitial ad unit id.
    Requests an interstitial ad. This function should be called every time a new ad is needed.
  • love.ads.isInterstitialLoaded()
    Check if the interstitial ad previously requested is ready to be shown.

    Returns:
    bool isAdReady: true if the ad is ready to be shown.
  • love.ads.showInterstitial()
    Displays the interstitial ad. May be called only if the ad is loaded.
  • love.ads.requestRewardedAd(string adUnitID)
    string adUnitID : Your rewarded ad unit id.
    Requests a rewarded video ad. This function should be called every time a new ad is needed.
  • love.ads.isRewardedAdLoaded()
    Check if the rewarded video ad previously requested is ready to be shown.

    Returns:
    bool isAdReady: true if the ad is ready to be shown.
  • love.ads.showRewardedAd()
    Displays the rewarded video ad. May be called only if the ad is loaded.
love.ads Callbacks
  • love.interstitialFailedToLoad()
    Fired when an interstitial ad fails to load.
  • love.interstitialClosed()
    Fired when the user closes an interstitial ad.
  • love.rewardedAdFailedToLoad()
    Fired when a rewarded video ad fails to load.
  • love.rewardUserWithReward(string rewardType,number rewardQuantity)
    string rewardType : The type of the reward you set in your AdMob dashboard.
    number rewardQuantity : The quantity of rewards you set in you AdMob dashboard.

    Fired when a rewarded video ad successfully finishes playing.
  • love.rewardedAdDidStop()
    Fired when a rewarded video ad is closed by the user.
    This callback is fired even if the video has already finished.

Here you can download the source:
https://drive.google.com/open?id=0B_qJq ... XpvUmRPZms

In order to use it, you need to set up the project like with the normal LÖVE iOS source.

Included in the source, there is an example game.love.
IMG_2672.PNG
IMG_2672.PNG (81.15 KiB) Viewed 3364 times
Note: all the Ad-Unit IDs in the game.love are from this url.
Last edited by bio1712 on Mon Aug 07, 2017 4:15 pm, edited 1 time in total.

User avatar
yetneverdone
Party member
Posts: 302
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: AdMob support for iOS!

Post by yetneverdone » Mon Jul 24, 2017 9:50 am

Cool! That's what i was waiting for. Thanks.

Anyways, i have question:
1. What do you need to build a project with that added functions?

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

Re: AdMob support for iOS!

Post by bio1712 » Mon Jul 24, 2017 11:49 am

yetneverdone wrote:
Mon Jul 24, 2017 9:50 am
Cool! That's what i was waiting for. Thanks.

Anyways, i have question:
1. What do you need to build a project with that added functions?
Hi, thanks for replying.
To build this project you need only the source, and you build it like you built the official love project.
The love.ads module is automatically required by your game.love.

User avatar
Rucikir
Party member
Posts: 123
Joined: Tue Nov 05, 2013 6:33 pm
Location: Paris
Contact:

Re: AdMob support for iOS!

Post by Rucikir » Mon Jul 24, 2017 12:56 pm

You could fork LÖVE git repository and branch from 0.10.2, and apply your changes here. It will be easier to maintain and to use.
Lua script to distribute your LÖVE games. love-release.lua : Forum | Github
@Rucikir

User avatar
yetneverdone
Party member
Posts: 302
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: AdMob support for iOS!

Post by yetneverdone » Mon Jul 24, 2017 1:24 pm

I agree with ruckir

User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: AdMob support for iOS!

Post by Marty » Sun Jan 07, 2018 9:46 pm

First of all, thank you for your great work.

Please make it easier to find the place where I have to put the App ID. On Android there is a string "YOUR-APP-ID-HERE" that is easy to spot in the AdActivity. However, this thing is missing in the Ads.mm and I was not able to spot it anywhere so far.

Where is it located?
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: AdMob support for iOS!

Post by Marty » Fri Mar 23, 2018 2:34 am

For everybody having the same issue, here is what worked for me.

I replaced the constructor of the modules/ads/Ads.mm to

Code: Select all

Ads::Ads()
{
	[GADMobileAds configureWithApplicationID:@"YOUR_ADMOB_APP_ID"];
}
with my proper App-ID of course.


Also if you want to test it with real ads, make sure you configure your payment methods on the admob platform.
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

Re: AdMob support for iOS!

Post by bio1712 » Fri Mar 23, 2018 3:13 pm

modiX wrote:
Sun Jan 07, 2018 9:46 pm
First of all, thank you for your great work.

Please make it easier to find the place where I have to put the App ID. On Android there is a string "YOUR-APP-ID-HERE" that is easy to spot in the AdActivity. However, this thing is missing in the Ads.mm and I was not able to spot it anywhere so far.

Where is it located?
Hi, I'm sorry I haven't seen this post before. Please forgive me.

As you have noticed, I've replied here.

deulamco
Prole
Posts: 1
Joined: Fri Apr 27, 2018 6:58 am

Re: AdMob support for iOS!

Post by deulamco » Fri Apr 27, 2018 7:00 am

Hello there, would you mind making a pull request to the official LOVE2D hub ?
So the Ads ( and future IAP module ) could come along with new version :D

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests