Hello colleagues.
Added to your application display advertising banners. When launched in the simulator, the following error messages appear on the console:
ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:) ... Code = 4 "
The same errors but in the Russian localization look like this:
Code = 4 "There is an iAd network configuration error in the program"
Code = 5 "The banner display mode is enabled, but the banner is empty"
The problem comes down to the fact that the banner is not displayed.
I studied the Internet on this topic, basically all the answers are reduced to the fact that you need to specify a delegate, or implement the didFailToReceiveAdWithError method. I appointed a delegate. If you implement an error handling method, the error is not output to the console, but this does not solve the problems.
import UIKit import iAd import StoreKit class ViewController: UIViewController, ADBannerViewDelegate, SKProductsRequestDelegate, SKPaymentTransactionObserver { @IBOutlet weak var restorePurchases: UIButton! @IBOutlet weak var removeAdButton: UIButton! @IBOutlet weak var adBanner: ADBannerView! var productToPurchase = SKProduct() override func viewDidLoad() { super.viewDidLoad() adBanner.hidden = false adBanner.delegate = self removeAdButton.hidden = false let userDefault = NSUserDefaults.standardUserDefaults() let paymentQueue = SKPaymentQueue.defaultQueue() if userDefault.objectForKey("Advert") == nil { paymentQueue.addTransactionObserver(self) getProductInformation() } if let transactionState = userDefault.objectForKey("Advert") { if transactionState as! String == "Purchased" { adBanner.removeFromSuperview() removeAdButton.hidden = true removeAdButton.enabled = false } else { paymentQueue.addTransactionObserver(self) getProductInformation() } }
} `
I quote a part of the code in order to show that I have appointed a delegate. If necessary, I can lay out the rest of the code.
In addition, the disable advertising button does not work. When you click on it, a message appears on the console: Error: nil, and then alert the "Sign In" controller. I click on the Use Existing Apple ID and get an error in reply:
Can not connect to iTunes Store. In the console, I get the following: "Error: Optional (Error Domain = SKErrorDomain Code = 0" Cannot connect to iTunes Store "UserInfo = {NSLocalizedDescription = Cannot connect to iTunes Store})"
I understand that these things are interrelated and if one problem is solved, then the second one will be solved. Although I could be wrong.
All this I test in the simulator. Maybe because of this, the whole problem? From my account from aytyuns and in appstore I left.
I connected a real device, now I managed to make an in-line purchase. There are no errors on the console, but the banner is still empty. Is this how it should be?