ios - Remove all iAds app wide? -
i've added in app purchases remove iads ios app.
i've put in logic once removeads product bought (which triggers):
func removeads() { defaults.setobject("true", forkey: "remove_adverts") self.candisplaybannerads = false self.removeadbutton.enabled = false println("removed") }
and i've put @ top of each controller handle it.
if let showads = defaults.dataforkey("remove_adverts") { self.candisplaybannerads = false self.removeadbutton.enabled = false println("ads shouldn't show") } else { self.candisplaybannerads = true }
but ads still show.
is there better way this?
when you're checking see if user has purchased iap remove ads in line if let showads = defaults.dataforkey("remove_adverts")
you're checking dataforkey
when should checking objectforkey
because used setobject
when setting default
value. alternatively, use setbool
code this:
func removeads() { defaults.setbool(true, forkey: "removeadspurchased") self.candisplaybannerads = false println("iad removed , default value set") defaults.synchronize() }
and
let showads = defaults.boolforkey("removeadspurchased") if (showads) { // user purchsed iap // lets remove ads self.candisplaybannerads = false println("iad removed") } else { // iap not purchased // lets show ads self.candisplaybannerads = true println("showing iad") }
Comments
Post a Comment