Skip to content

Commit

Permalink
feat/pre_release_improvements (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
wootaejeon authored Feb 5, 2024
2 parents f05e689 + 1d84ab6 commit a6a3085
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 123 deletions.
38 changes: 19 additions & 19 deletions example/ads.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ local log = require("example.log")

local M = {}

local ios_ad_units = {
local ios_ad_unit_ids = {
Interstitial = "ENTER_IOS_INTERSTITIAL_AD_UNIT_ID_HERE",
Rewarded = "ENTER_IOS_REWARDED_AD_UNIT_ID_HERE",
Banner = "ENTER_IOS_BANNER_AD_UNIT_ID_HERE",
MRec = "ENTER_ANDROID_MREC_AD_UNIT_ID_HERE"
MRec = "ENTER_IOS_MREC_AD_UNIT_ID_HERE"
}

local android_ad_units = {
local android_ad_unit_ids = {
Interstitial = "ENTER_ANDROID_INTERSTITIAL_AD_UNIT_ID_HERE",
Rewarded = "ENTER_ANDROID_REWARDED_AD_UNIT_ID_HERE",
Banner = "ENTER_ANDROID_BANNER_AD_UNIT_ID_HERE",
Expand All @@ -20,7 +20,7 @@ local android_ad_units = {
local ui_components = {}

local selected_ad_type = ""
local ad_unit = ""
local ad_unit_id = ""
local isShowingAd = false;

local function reset_ui_components()
Expand All @@ -40,25 +40,25 @@ end

local function load_ad()
if selected_ad_type == "Interstitial" then
applovin.load_interstitial(ad_unit)
applovin.load_interstitial(ad_unit_id)
elseif selected_ad_type == "Rewarded" then
applovin.load_rewarded_ad(ad_unit)
applovin.load_rewarded_ad(ad_unit_id)
elseif selected_ad_type == "Banner" then
applovin.create_banner(ad_unit, "top_center")
applovin.create_banner(ad_unit_id, "top_center")
elseif selected_ad_type == "MRec" then
applovin.create_mrec(ad_unit, "centered")
applovin.create_mrec(ad_unit_id, "centered")
end
end

local function show_ad()
if selected_ad_type == "Interstitial" then
applovin.show_interstitial(ad_unit)
applovin.show_interstitial(ad_unit_id)
elseif selected_ad_type == "Rewarded" then
applovin.show_rewarded_ad(ad_unit)
applovin.show_rewarded_ad(ad_unit_id)
elseif selected_ad_type == "Banner" then
applovin.show_banner(ad_unit)
applovin.show_banner(ad_unit_id)
elseif selected_ad_type == "MRec" then
applovin.show_mrec(ad_unit)
applovin.show_mrec(ad_unit_id)
end
end

Expand All @@ -69,9 +69,9 @@ function M.setup(ad_type)

local sysinfo = sys.get_sys_info()
if sysinfo.system_name == "Android" then
ad_unit = android_ad_units[ad_type]
ad_unit_id = android_ad_unit_ids[ad_type]
elseif sysinfo.system_name == "iPhone OS" then
ad_unit = ios_ad_units[ad_type]
ad_unit_id = ios_ad_unit_ids[ad_type]
end

gui.set_text(ui_components.ad_type_text, ad_type)
Expand All @@ -91,7 +91,7 @@ function M.on_load_button_clicked()
end

function M.on_ad_loaded(params)
if not isShowingAd and params.adUnitIdentifier == ad_unit then
if not isShowingAd and params.adUnitIdentifier == ad_unit_id then
gui.set_text(ui_components.load_button_label, "Show")
gui.set_enabled(ui_components.load_button, true)
gui.set_enabled(ui_components.loading_text, false)
Expand All @@ -100,11 +100,11 @@ end

function M.on_back_button_clicked()
if selected_ad_type == "Banner" then
applovin.hide_banner(ad_unit)
applovin.destroy_banner(ad_unit)
applovin.hide_banner(ad_unit_id)
applovin.destroy_banner(ad_unit_id)
elseif selected_ad_type == "MRec" then
applovin.hide_mrec(ad_unit)
applovin.destroy_mrec(ad_unit)
applovin.hide_mrec(ad_unit_id)
applovin.destroy_mrec(ad_unit_id)
end

isShowingAd = false
Expand Down
Loading

0 comments on commit a6a3085

Please sign in to comment.