Reputation: 227
I am currently developing an iOS app in Swift 2.0 and decided to use Millennial Media for their Ads. All their documentation refers to Objective-C codes and, although it's not much code at all, I cannot figure out how to port them over Swift.
I tried to search on StackOverflow and on Google but couldn't find anything at all.
I am trying to port the following:
Thank you.
Upvotes: 0
Views: 176
Reputation: 179
The following code worked for me in Swift.
Make sure you have the following in your bridging header:
#import <MMAdSDK/MMAdSDK.h>
Make sure to include the delegate in your class header:
class MyClass : UIViewController, MMInterstitialDelegate {
Declare your ad as a var:
var interstitialAd = MMInterstitialAd(placementId: "123456")
Call the following inside your viewDidLoad() method:
interstitialAd?.delegate = self
interstitialAd?.load(nil)
Use the following to display the Ad:
if ((interstitialAd?.ready) != nil) {
interstitialAd?.showFromViewController(self)
}
Upvotes: 0
Reputation: 227
I solved it by integrating the Google AdMob mediation adapter. Once integrated, everything is easily managed via the Google backend.
Upvotes: 0