Vungle and AdMob best practices

Hi guys  :smiley:

I am just finishing my first game and it tends to crash when calling “ads.show” at my level.lua after gameOver:

level.lua

-- scene:show() ads:setCurrentProvider( "vungle" )  function gameOver() ads.show( "interstitial",  { isAnimated = false,  isAutoRotation = true } ) end

In order to prevent this can you please give me few advices (best practices):

  1. Should I make “ads” a global variable (i.e. reachable for all composer scenes) or call it locally in every single scene like this?

    local ads = require “ads”

  2. Where should I create ads listener functions, where should I “setCurrentProviders” ?

Obviously I have three options: create it at top level code, at scene:create or scene:show?

  1. Is there a need to display.remove and nil “ads” variable when changing scenes (at scene:hide section)?

Waiting your reply!

Many thanks!   :smiley:

Ivan