Search code examples
objective-cswiftinterstitial

What is the best way to create a custom popup interstitial ad?


I currently have an app written in objc and swift.

I would like to implement a custom popup interstitial ad that runs for a few seconds and then presents an X to close the popup and continues doing so every couple minutes unless the Remove Ad's in-ap purchase has been purchased.

I already have the in-app purchases setup. I would really appreciate the help or a demo/sample would be fantastic!


Solution

  • Create a separate controller with an image view which will popup according to the timer set in app delegate. close X should also have a timer

     func applicationDidEnterBackground(application: UIApplication) {
    
        if (!isShowingAd && adTimer != nil) {
            adTimerTimeLeft = adTimer!.fireDate.timeIntervalSinceNow
            adTimer!.invalidate()
        }
    
        if adUpdateTimer != nil
        {
            adUpdateTimerTimeLeft = 60 * 60 //one hour
            self.adUpdateTimer!.invalidate()
        }
    }
    

    //setting timer, This way you can set timer

    var adTimer: NSTimer? 
    timer = NSTimer.scheduledTimerWithTimeInterval(10.0, target: self, selector: #selector(AppDelegate.updateAd), userInfo: nil, repeats: true)
       timer?.fire()