defold / extension-fbinstant

Facebook Instant Games extension for the Defold game engine
https://defold.com/extension-fbinstant/
MIT License
38 stars 20 forks source link

Ads not loading more than once #57

Closed dinindu-d closed 5 years ago

dinindu-d commented 5 years ago

I’m trying to load Facebook instant game ads several times using two placement IDs using bellow functionality,

-- Preload ad unit
function load_ad_unit(ad_unit_id)
    print("loading ad unit...")
    fbinstant.load_interstitial_ad(
        ad_unit_id,
        function(self, success)
            if success then
                print("Ad unit successfully loaded ")
            else
                print("Ad unit doesn't loaded ", ad_unit_id)
            end
        end
    )
end

-- Show ad unit
function show_ad_unit(ad_unit_id)
    fbinstant.show_interstitial_ad(
        ad_unit_id,
        function(self, success)
            if success then
                print("Ad unit successfully opened ", ad_unit_id)
                -- * I put this here because `show_interstitial_ad`
                -- handles removing the ad instance
                load_ad_unit(ad_unit_id)
            else
                print("Ad unit doesn't opened ", ad_unit_id)
            end
        end
    )
end

function on_message(self, message_id, message, sender)
    if message_id == hash("NEW_GAME") then
        load_ad_unit("<ad_unit_id>")
    elseif message_id == hash("ON_PRESS") then
        show_ad_unit("<ad_unit_id>")
    end
end

But this only works once at the beginning of the game when I press a button. For the second time, it won't work. Below are errors that occur in most situations,

> FBInstant_PlatformShowInterstitialAdAsync - unable to find ad. Did you load it?
> FBInstant_PlatformLoadInterstitialAdAsync - error a {code: "ADS_NO_FILL", message: "No fill"}
> FBInstant_PlatformLoadInterstitialAdAsync - error a {code: "ADS_TOO_MANY_INSTANCES", message: "Too many ad instances"}

This issue is from the forum: https://forum.defold.com/t/facebook-instant-games-ads-not-loading-more-than-once/43392

britzl commented 5 years ago

Investigating.

britzl commented 5 years ago

Found the problem. Working on a fix.

britzl commented 5 years ago

Fixed in 5.0.0. Note the new API:

https://github.com/defold/extension-fbinstant/releases/tag/5.0.0

Please report any problems you might have!