|
@@ -42,47 +42,56 @@ class ViewController: UIViewController {
|
|
|
|
|
|
let appBundleId = "com.musevisions.iOS.SwiftyStoreKit"
|
|
let appBundleId = "com.musevisions.iOS.SwiftyStoreKit"
|
|
|
|
|
|
- // MARK: non consumable
|
|
|
|
|
|
+#if os(iOS)
|
|
|
|
+ // UISwitch is unavailable on tvOS
|
|
@IBOutlet var nonConsumableAtomicSwitch: UISwitch!
|
|
@IBOutlet var nonConsumableAtomicSwitch: UISwitch!
|
|
-
|
|
|
|
|
|
+ @IBOutlet var consumableAtomicSwitch: UISwitch!
|
|
|
|
+ @IBOutlet var nonRenewingAtomicSwitch: UISwitch!
|
|
|
|
+ @IBOutlet var autoRenewableAtomicSwitch: UISwitch!
|
|
|
|
+ var nonConsumableIsAtomic: Bool { return nonConsumableAtomicSwitch.isOn }
|
|
|
|
+ var consumableIsAtomic: Bool { return consumableAtomicSwitch.isOn }
|
|
|
|
+ var nonRenewingIsAtomic: Bool { return nonRenewingAtomicSwitch.isOn }
|
|
|
|
+ var autoRenewableIsAtomic: Bool { return autoRenewableAtomicSwitch.isOn }
|
|
|
|
+#else
|
|
|
|
+ var nonConsumableIsAtomic = true
|
|
|
|
+ var consumableIsAtomic = true
|
|
|
|
+ var nonRenewingIsAtomic = true
|
|
|
|
+ var autoRenewableIsAtomic = true
|
|
|
|
+#endif
|
|
|
|
+ // MARK: non consumable
|
|
@IBAction func nonConsumableGetInfo() {
|
|
@IBAction func nonConsumableGetInfo() {
|
|
getInfo(.nonConsumablePurchase)
|
|
getInfo(.nonConsumablePurchase)
|
|
}
|
|
}
|
|
@IBAction func nonConsumablePurchase() {
|
|
@IBAction func nonConsumablePurchase() {
|
|
- purchase(.nonConsumablePurchase, atomically: nonConsumableAtomicSwitch.isOn)
|
|
|
|
|
|
+ purchase(.nonConsumablePurchase, atomically: nonConsumableIsAtomic)
|
|
}
|
|
}
|
|
@IBAction func nonConsumableVerifyPurchase() {
|
|
@IBAction func nonConsumableVerifyPurchase() {
|
|
verifyPurchase(.nonConsumablePurchase)
|
|
verifyPurchase(.nonConsumablePurchase)
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: consumable
|
|
// MARK: consumable
|
|
- @IBOutlet var consumableAtomicSwitch: UISwitch!
|
|
|
|
-
|
|
|
|
@IBAction func consumableGetInfo() {
|
|
@IBAction func consumableGetInfo() {
|
|
getInfo(.consumablePurchase)
|
|
getInfo(.consumablePurchase)
|
|
}
|
|
}
|
|
@IBAction func consumablePurchase() {
|
|
@IBAction func consumablePurchase() {
|
|
- purchase(.consumablePurchase, atomically: consumableAtomicSwitch.isOn)
|
|
|
|
|
|
+ purchase(.consumablePurchase, atomically: consumableIsAtomic)
|
|
}
|
|
}
|
|
@IBAction func consumableVerifyPurchase() {
|
|
@IBAction func consumableVerifyPurchase() {
|
|
verifyPurchase(.consumablePurchase)
|
|
verifyPurchase(.consumablePurchase)
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: non renewing
|
|
// MARK: non renewing
|
|
- @IBOutlet var nonRenewingAtomicSwitch: UISwitch!
|
|
|
|
-
|
|
|
|
@IBAction func nonRenewingGetInfo() {
|
|
@IBAction func nonRenewingGetInfo() {
|
|
getInfo(.nonRenewingPurchase)
|
|
getInfo(.nonRenewingPurchase)
|
|
}
|
|
}
|
|
@IBAction func nonRenewingPurchase() {
|
|
@IBAction func nonRenewingPurchase() {
|
|
- purchase(.nonRenewingPurchase, atomically: nonRenewingAtomicSwitch.isOn)
|
|
|
|
|
|
+ purchase(.nonRenewingPurchase, atomically: nonRenewingIsAtomic)
|
|
}
|
|
}
|
|
@IBAction func nonRenewingVerifyPurchase() {
|
|
@IBAction func nonRenewingVerifyPurchase() {
|
|
verifyPurchase(.nonRenewingPurchase)
|
|
verifyPurchase(.nonRenewingPurchase)
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: auto renewable
|
|
// MARK: auto renewable
|
|
- @IBOutlet var autoRenewableAtomicSwitch: UISwitch!
|
|
|
|
@IBOutlet var autoRenewableSubscriptionSegmentedControl: UISegmentedControl!
|
|
@IBOutlet var autoRenewableSubscriptionSegmentedControl: UISegmentedControl!
|
|
|
|
|
|
var autoRenewableSubscription: RegisteredPurchase {
|
|
var autoRenewableSubscription: RegisteredPurchase {
|
|
@@ -97,7 +106,7 @@ class ViewController: UIViewController {
|
|
getInfo(autoRenewableSubscription)
|
|
getInfo(autoRenewableSubscription)
|
|
}
|
|
}
|
|
@IBAction func autoRenewablePurchase() {
|
|
@IBAction func autoRenewablePurchase() {
|
|
- purchase(autoRenewableSubscription, atomically: autoRenewableAtomicSwitch.isOn)
|
|
|
|
|
|
+ purchase(autoRenewableSubscription, atomically: autoRenewableIsAtomic)
|
|
}
|
|
}
|
|
@IBAction func autoRenewableVerifyPurchase() {
|
|
@IBAction func autoRenewableVerifyPurchase() {
|
|
verifyPurchase(autoRenewableSubscription)
|
|
verifyPurchase(autoRenewableSubscription)
|