Search code examples
iosswiftxcodemobfox

Connecting iOS app with MobFox


I followed the documentation to add MobFox ads in my application. For some reason I am getting the error : Could not connect to the server.

func mobFoxAdDidFailToReceiveAdWithError(_ error:Error!) {
        print("MobFoxAdDidFailToReceiveAdWithError: ", error.localizedDescription)
    }

And it gives: MobFoxAdDidFailToReceiveAdWithError: Could not connect to the server.

 private var mobfoxAd: MobFoxAd!
    override func viewDidLoad() {
            super.viewDidLoad()
    let rect = CGRect(origin: CGPoint(x: 0, y: 200), size: CGSize(width:320, height: 50))
            mobfoxAd = MobFoxAd("fe96717d9875b9da4339ea5367eff1ec", withFrame: rect)
            mobfoxAd.delegate = self
            mobfoxAd.refresh = adRefresh as NSNumber?
            self.view.addSubview(mobfoxAd)
        }

In my Info.plist file, I have added.

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

I don't seem to find the reason. Thanks.


Solution

  • Turns out the countries where these services are not provided are not mentioned. If you face this problem, change to another country with VPN. Ads will appear.