Eliko
Eliko

Reputation: 1137

The Ads do not get deleted after In-App purchase in Swift

I made an app that a offer only one In-App Purchase to delete the Ads & etc.

I have all the code I need to make the In-App purchase when I test it - the etc works (for example: new modes in the app) but the ads do not get removed.

This is what I tried:

if defaults.boolForKey("removeAds") == true {


        canDisplayBannerAds = false
        adBannerView?.delegate = self
        adBannerView?.hidden = true
        adBannerView!.removeFromSuperview()

Upvotes: 0

Views: 57

Answers (1)

mclaughj
mclaughj

Reputation: 12865

It's hard to tell what the problem is with such little information surrounding your implementation, but one thing to verify is that you're running any code that affects the UI on the main thread.

For example, you could try surrounding that block of UI-modifying code with a dispatch_async block:

if defaults.boolForKey("removeAds") == true {
    dispatch_async(dispatch_get_main_queue(), {
        self.canDisplayBannerAds = false
        self.adBannerView?.delegate = self
        self.adBannerView?.hidden = true
        self.adBannerView!.removeFromSuperview()
    }
}

Please notice also that inside the dispatch_async block, you need to reference your properties using self to avoid ambiguity.

Upvotes: 1

Related Questions