Skip to content

Instantly share code, notes, and snippets.

@ngs
Created October 2, 2014 00:59
Show Gist options
  • Save ngs/902f0aeeea2417dc7347 to your computer and use it in GitHub Desktop.
Save ngs/902f0aeeea2417dc7347 to your computer and use it in GitHub Desktop.
//
// StoreKitExampleViewController.swift
// StoreKitTest
//
// Created by Atsushi Nagase on 10/2/14.
// Copyright (c) 2014 Atsushi Nagase. All rights reserved.
//
import UIKit
import StoreKit
class ViewController: UIViewController, SKStoreProductViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonTapped(sender: AnyObject) {
var vc: SKStoreProductViewController = SKStoreProductViewController()
var params = [
SKStoreProductParameterITunesItemIdentifier:451923559,
SKStoreProductParameterAffiliateToken:"10l87J",
SKStoreProductParameterCampaignToken:"onairlog813"
]
vc.delegate = self
vc.loadProductWithParameters(params, completionBlock: nil)
self.presentViewController(vc, animated: true) { () -> Void in }
}
func productViewControllerDidFinish(viewController: SKStoreProductViewController!) {
viewController.dismissViewControllerAnimated(true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment