This repository has been archived on 2025-03-19. You can view files and clone it, but cannot push or open issues or pull requests.
TapeDeck/grandfatherrock/ThirdViewController.swift
2021-03-25 15:48:16 -06:00

68 lines
1.6 KiB
Swift

//
// SecondViewController.swift
// grandfatherrock
//
// Created by Micah Gomez on 4/15/20.
// Copyright © 2020 Micah Gomez. All rights reserved.
//
import UIKit
import MediaPlayer
class ThirdViewController: UIViewController {
@IBAction func websiteButton(_ sender: Any) {
if let url = URL(string: "https://micahpgomez.com") {
UIApplication.shared.open(url)
}
}
@IBAction func privacyButton(_ sender: Any) {
if let url = URL(string: "https://micahpgomez.dev/Privacy.html") {
UIApplication.shared.open(url)
}
}
@IBAction func supportEmail(_ sender: Any) {
if let url = URL(string: "mailto:support@micahpgomez.com") {
UIApplication.shared.open(url)
}
}
@IBAction func smallTipButton(_ sender: Any) {
IAPHandler.shared.purchaseMyProduct(index: 2)
}
@IBAction func mediumTipButton(_ sender: Any) {
IAPHandler.shared.purchaseMyProduct(index: 1)
}
@IBAction func largeTipButton(_ sender: Any) {
IAPHandler.shared.purchaseMyProduct(index: 0)
}
let defaults = UserDefaults.standard
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//print("view loaded!")
IAPHandler.shared.fetchAvailableProducts()
IAPHandler.shared.purchaseStatusBlock = {[weak self] (type) in
guard let strongSelf = self else{ return }
if type == .purchased {
let alertView = UIAlertController(title: type.title(), message: type.message(), preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: { (alert) in
})
alertView.addAction(action)
strongSelf.present(alertView, animated: true, completion: nil)
}
}
}
}