Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean the rep + swiftLint #164

Merged
merged 27 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ osx_image: xcode8
before_script: "./scripts/add-keys.sh"
after_script: "./scripts/remove-key.sh"
script:
- "./scripts/swiftLint.sh
- "./scripts/buildPrebidMobile.sh"
- "./scripts/testPrebidMobile.sh"
- "./scripts/testPrebidMobile.sh"
20 changes: 8 additions & 12 deletions example/Swift/PrebidDemo/PrebidDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Copyright 2018-2019 Prebid.org, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -18,34 +18,32 @@ import PrebidMobile
import CoreLocation

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

var coreLocation:CLLocationManager?
var coreLocation: CLLocationManager?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

//Declare in AppDelegate to the user agent could be passed in first call
Prebid.shared.prebidServerAccountId = "bfa84af2-bd16-4d35-96ad-31c6bb888df0"
Prebid.shared.shareGeoLocation = true
//Prebid.shared.timeoutMillis = 1000;
//Prebid.shared.prebidServerHost = PrebidHost.Rubicon
//Prebid.shared.prebidServerAccountId = "12345"

coreLocation = CLLocationManager()
coreLocation?.requestWhenInUseAuthorization()

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

Expand All @@ -61,6 +59,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

85 changes: 40 additions & 45 deletions example/Swift/PrebidDemo/PrebidDemo/BannerController.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Copyright 2018-2019 Prebid.org, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -22,115 +22,110 @@ import GoogleMobileAds
import MoPub

class BannerController: UIViewController, GADBannerViewDelegate, MPAdViewDelegate {

@IBOutlet var appBannerView: UIView!

@IBOutlet var adServerLabel: UILabel!
var adServerName:String = ""

var adServerName: String = ""

let request = DFPRequest()

var dfpBanner: DFPBannerView!

var bannerUnit: BannerAdUnit!

var mopubBanner: MPAdView?

override func viewDidLoad() {
super.viewDidLoad()

adServerLabel.text = adServerName

bannerUnit = BannerAdUnit(configId: "6ace8c7d-88c0-4623-8117-75bc3f0a2e45", size: CGSize(width: 300, height: 250))
bannerUnit.setAutoRefreshMillis(time: 35000)
//bannerUnit.addAdditionalSize(sizes: [CGSize(width: 300, height: 600)])
if(adServerName == "DFP"){

if (adServerName == "DFP") {
print("entered \(adServerName) loop" )
loadDFPBanner(bannerUnit: bannerUnit)
} else if (adServerName == "MoPub"){

} else if (adServerName == "MoPub") {
print("entered \(adServerName) loop" )
loadMoPubBanner(bannerUnit: bannerUnit)

}
}

override func viewDidDisappear(_ animated: Bool) {
// important to remove the time instance
bannerUnit?.stopAutoRefresh()
}
func loadDFPBanner(bannerUnit : AdUnit){

func loadDFPBanner(bannerUnit: AdUnit) {
print("Google Mobile Ads SDK version: \(DFPRequest.sdkVersion())")
dfpBanner = DFPBannerView(adSize: kGADAdSizeMediumRectangle)
dfpBanner.adUnitID = "/19968336/PrebidMobileValidator_Banner_All_Sizes"
dfpBanner.rootViewController = self
dfpBanner.delegate = self
dfpBanner.backgroundColor = .red
appBannerView.addSubview(dfpBanner)
request.testDevices = [ kGADSimulatorID,"cc7ca766f86b43ab6cdc92bed424069b"]

request.testDevices = [ kGADSimulatorID, "cc7ca766f86b43ab6cdc92bed424069b"]
bannerUnit.fetchDemand(adObject:self.request) { [weak self] (ResultCode) in
print("Prebid demand fetch for DFP \(ResultCode.name())")
self?.dfpBanner!.load(self?.request)
}
}
func loadMoPubBanner(bannerUnit: AdUnit){

func loadMoPubBanner(bannerUnit: AdUnit) {

let sdkConfig = MPMoPubConfiguration(adUnitIdForAppInitialization: "a935eac11acd416f92640411234fbba6")
sdkConfig.globalMediationSettings = []

MoPub.sharedInstance().initializeSdk(with: sdkConfig) {

}

mopubBanner = MPAdView(adUnitId: "a935eac11acd416f92640411234fbba6", size: CGSize(width: 300, height: 250))
mopubBanner!.delegate = self

appBannerView.addSubview(mopubBanner!)

// Do any additional setup after loading the view, typically from a nib.
bannerUnit.fetchDemand(adObject: mopubBanner!){ (ResultCode) in
bannerUnit.fetchDemand(adObject: mopubBanner!) { (ResultCode) in
print("Prebid demand fetch for mopub \(ResultCode)")

self.mopubBanner!.loadAd()
}

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func adViewDidReceiveAd(_ bannerView: GADBannerView) {
print("adViewDidReceiveAd")
}

func adView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: GADRequestError) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}

func adViewDidReceiveAd(_ bannerView: DFPBannerView) {
print("adViewDidReceiveAd")
}

/// Tells the delegate an ad request failed.
func adView(_ bannerView: DFPBannerView,
didFailToReceiveAdWithError error: GADRequestError) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}

func viewControllerForPresentingModalView() -> UIViewController! {
return self
}





}

26 changes: 11 additions & 15 deletions example/Swift/PrebidDemo/PrebidDemo/IndexController.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Copyright 2018-2019 Prebid.org, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -21,24 +21,20 @@ class IndexController: UIViewController {
@IBOutlet var adServerSegment: UISegmentedControl!
override func viewDidLoad() {
super.viewDidLoad()

self.title = "Prebid Demo"
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
if segue.destination is BannerController
{

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.destination is BannerController {
let vc = segue.destination as? BannerController
vc?.adServerName = adServerSegment.titleForSegment(at: adServerSegment.selectedSegmentIndex)!
vc?.adServerName = adServerSegment.titleForSegment(at: adServerSegment.selectedSegmentIndex)!
}

if segue.destination is InterstitialViewController
{

if segue.destination is InterstitialViewController {
let vc = segue.destination as? InterstitialViewController
vc?.adServerName = adServerSegment.titleForSegment(at: adServerSegment.selectedSegmentIndex)!
}
}



}
Loading