Skip to content

Instantly share code, notes, and snippets.

@ydn
ydn / setup_location_manager.swift
Created June 10, 2015 23:28
Track geographic location (Swift)
let locationManager: CLLocationManager = CLLocationManager();
locationManager.startUpdatingLocation();
@ydn
ydn / flurry_timed_event_with_param.swift
Last active August 29, 2015 14:22
Capture Event Duration
// Capture the author info & user status
let articleParams = ["Author": "John Q", "User_Status": "Registered"];
Flurry.logEvent("Article_Read", withParameters: articleParams, timed: true);
// In a function that captures when a user navigates away from article
// You can pass in additional params or update existing ones here as well
Flurry.endTimedEvent("Article_Read", withParameters: nil);
@ydn
ydn / Flurry_event_simple.swift
Created June 10, 2015 23:16
Simple Flurry Event (Swift)
Flurry.logEvent("Article_Read");
@ydn
ydn / Flurry_event_with_parameters.swift
Created June 10, 2015 23:13
Flurry Event with Parameters (Swift Example)
// Capture the author info & user status
let articleParams = ["Author": "John Q", "User_Status": "Registered"];
Flurry.logEvent("Article_Read", withParameters: articleParams);
@ydn
ydn / FlurryAdsTargetingExamples.swift
Created June 10, 2015 23:04
Configure Ad Serving (Swift)
// Example of enabling the test mode
{
let adInterstitial = FlurryAdInterstitial(space:"ADSPACE");
adInterstitial.adDelegate = self;
let adTargeting = FlurryAdTargeting();
adTargeting.testAdsEnabled = true;
adInterstitial.targeting = adTargeting;
adInterstitial.fetchAd();
}
@ydn
ydn / FlurryAdInterstitialCallbacks.swift
Created June 10, 2015 22:24
Flurry Full-Screen Ad Integration callbacks (Swift)
class ViewController: UIViewController, FlurryAdInterstitialDelegate {
func adInterstitialDidFetchAd(interstitialAd: FlurryAdInterstitial!) {
// You can choose to present the ad as soon as it is received
interstitialAd.presentWithViewController(self);
}
// Invoked when the interstitial ad is rendered
func adInterstitialDidRender(interstitialAd: FlurryAdInterstitial!) {
@ydn
ydn / FlurryForPublishers_Interstitial.swift
Last active August 29, 2015 14:22
Full-Screen Ads (complete example) with Swift
class ViewController: UIViewController, FlurryAdInterstitialDelegate {
let adInterstitial = FlurryAdInterstitial(space:"ADSPACE");
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated);
adInterstitial.adDelegate = self;
adInterstitial.fetchAd();
}
override func viewDidDisappear(animated: Bool) {
@ydn
ydn / FlurryAdBannerCallbacks.swift
Created June 10, 2015 21:55
Ad Banner Callbacks (Swift)
class ViewController: UIViewController, FlurryAdBannerDelegate {
// Invoked when an ad is received for the specified bannerAd object
func adBannerDidFetchAd(bannerAd: FlurryAdBanner!) { }
// Invoked when the banner ad is rendered
func adBannerDidRender(bannerAd: FlurryAdBanner!) { }
// Informational callback invoked when an ad is clicked for the specified @c bannerAd object
func adBannerDidReceiveClick(bannerAd: FlurryAdBanner!) { }
@ydn
ydn / FlurryForPublishers_Banner_sample_alt.swift
Last active August 29, 2015 14:22
Alternate Banner Sample (Full) with Swift
class ViewController: UIViewController, FlurryAdBannerDelegate {
let adBanner = FlurryAdBanner(space: "ADSPACE");
override func viewDidAppear(animated: Bool){
super.viewDidAppear(animated);
adBanner.adDelegate = self;
adBanner.fetchAdForFrame(self.view.frame);
}
// Show whenever delegate is invoked
@ydn
ydn / FlurryForPublishers_Banner_Full.swift
Created June 10, 2015 21:42
Banner Ad example (full) with Swift
class ViewController: UIViewController, FlurryAdBannerDelegate {
// Initialize ad space to fetch ads from
let adBanner = FlurryAdBanner(space: "ADSPACE");
override func viewDidAppear(animated: Bool){
super.viewDidAppear(animated);
// Fetch and display banner ad for a given ad space
adBanner.adDelegate = self;
adBanner.fetchAnddisplayAdInView(self.view, viewControllerForPresentation: self);
}