Skip to content
Permalink
Browse files

Replace IAHelper for SwiftyStoreKit

  • Loading branch information...
GianniCarlo committed Feb 27, 2019
1 parent 562f2a6 commit 7627c6392d2d5735ec73054e56e92965ae10a00c
@@ -45,7 +45,6 @@
416B640D1E72F362000E955A /* Notification+BookPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416B640C1E72F362000E955A /* Notification+BookPlayer.swift */; };
4175E1242206CF9600FB7B71 /* DataManager+CoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4175E1232206CF9600FB7B71 /* DataManager+CoreData.swift */; };
4175E14522080C7700FB7B71 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4175E14422080C7700FB7B71 /* StoreKit.framework */; };
4175E14722080D9300FB7B71 /* IAPHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4175E14622080D9300FB7B71 /* IAPHelper.swift */; };
41839AB320AA8B960047E55D /* Theme+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41839AB120AA8B960047E55D /* Theme+CoreDataClass.swift */; };
41839AB420AA8B960047E55D /* Theme+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41839AB220AA8B960047E55D /* Theme+CoreDataProperties.swift */; };
41839AB720AA8C970047E55D /* Book+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41839AB520AA8C970047E55D /* Book+CoreDataClass.swift */; };
@@ -81,6 +80,7 @@
41D39D41215F177D00B65290 /* BookActivityItemProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D39D40215F177D00B65290 /* BookActivityItemProvider.swift */; };
41D4F2EB2101A278009F1B1E /* DirectoryWatcher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41D4F2EA2101A278009F1B1E /* DirectoryWatcher.framework */; };
41D4F2EF21053944009F1B1E /* IndexPath+BookPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D4F2EE21053944009F1B1E /* IndexPath+BookPlayer.swift */; };
41D7944F22260EC000228580 /* SwiftyStoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41D7944E22260EC000228580 /* SwiftyStoreKit.framework */; };
41E34E502138EA8200A3997C /* ImportOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E34E4F2138EA8200A3997C /* ImportOperation.swift */; };
41E562C4223896B500C06BC9 /* UserDefaults+BookPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E562C3223896B500C06BC9 /* UserDefaults+BookPlayer.swift */; };
41E562CE22394F5200C06BC9 /* ayu-light@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 41E562CC22394F5200C06BC9 /* ayu-light@2x.png */; };
@@ -214,7 +214,6 @@
416B640C1E72F362000E955A /* Notification+BookPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Notification+BookPlayer.swift"; sourceTree = "<group>"; };
4175E1232206CF9600FB7B71 /* DataManager+CoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataManager+CoreData.swift"; sourceTree = "<group>"; };
4175E14422080C7700FB7B71 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
4175E14622080D9300FB7B71 /* IAPHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IAPHelper.swift; sourceTree = "<group>"; };
41839AB120AA8B960047E55D /* Theme+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+CoreDataClass.swift"; sourceTree = "<group>"; };
41839AB220AA8B960047E55D /* Theme+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+CoreDataProperties.swift"; sourceTree = "<group>"; };
41839AB520AA8C970047E55D /* Book+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Book+CoreDataClass.swift"; sourceTree = "<group>"; };
@@ -255,6 +254,7 @@
41D39D40215F177D00B65290 /* BookActivityItemProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookActivityItemProvider.swift; sourceTree = "<group>"; };
41D4F2EA2101A278009F1B1E /* DirectoryWatcher.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DirectoryWatcher.framework; path = Carthage/Build/iOS/DirectoryWatcher.framework; sourceTree = "<group>"; };
41D4F2EE21053944009F1B1E /* IndexPath+BookPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IndexPath+BookPlayer.swift"; sourceTree = "<group>"; };
41D7944E22260EC000228580 /* SwiftyStoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyStoreKit.framework; path = Carthage/Build/iOS/SwiftyStoreKit.framework; sourceTree = "<group>"; };
41E34E4F2138EA8200A3997C /* ImportOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOperation.swift; sourceTree = "<group>"; };
41E562C3223896B500C06BC9 /* UserDefaults+BookPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+BookPlayer.swift"; sourceTree = "<group>"; };
41E562CC22394F5200C06BC9 /* ayu-light@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ayu-light@2x.png"; sourceTree = "<group>"; };
@@ -347,6 +347,7 @@
5CBB29552163E57300E3A9FF /* ZIPFoundation.framework in Frameworks */,
41B2A6AC21D3274500917584 /* Themeable.framework in Frameworks */,
41AD3DB322205C5A00DC41E1 /* Kingfisher.framework in Frameworks */,
41D7944F22260EC000228580 /* SwiftyStoreKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -368,7 +369,6 @@
416B63A72146354B007D04B1 /* ImportManager.swift */,
41E34E4F2138EA8200A3997C /* ImportOperation.swift */,
41544A1121B86A8B00740AD2 /* DeleteMode.swift */,
4175E14622080D9300FB7B71 /* IAPHelper.swift */,
);
path = DataManagement;
sourceTree = "<group>";
@@ -446,6 +446,7 @@
isa = PBXGroup;
children = (
4112AFD5223AD27D00BFEA55 /* Sentry.framework */,
41D7944E22260EC000228580 /* SwiftyStoreKit.framework */,
41AD3DB222205C5A00DC41E1 /* Kingfisher.framework */,
4175E14422080C7700FB7B71 /* StoreKit.framework */,
41B2A6AB21D3274500917584 /* Themeable.framework */,
@@ -913,11 +914,9 @@
"$(SRCROOT)/Carthage/Build/iOS/DirectoryWatcher.framework",
"$(SRCROOT)/Carthage/Build/iOS/ZIPFoundation.framework",
"$(SRCROOT)/Carthage/Build/iOS/Themeable.framework",
<<<<<<< HEAD
"$(SRCROOT)/Carthage/Build/iOS/Sentry.framework",
=======
"$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework",
>>>>>>> dec2ee6... Setup collectionView with list of contributors from Github
"$(SRCROOT)/Carthage/Build/iOS/SwiftyStoreKit.framework",
);
name = "Copy Frameworks managed by Carthage";
outputPaths = (
@@ -929,11 +928,9 @@
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/DirectoryWatcher.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ZIPFoundation.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Themeable.framework",
<<<<<<< HEAD
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Sentry.framework",
=======
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Kingfisher.framework",
>>>>>>> dec2ee6... Setup collectionView with list of contributors from Github
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SwiftyStoreKit.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -995,7 +992,6 @@
4165EE0520A743D500616EDF /* BookPlayer.xcdatamodeld in Sources */,
4165EE0320A743D500616EDF /* Playlist+CoreDataClass.swift in Sources */,
41B2A5DC21CAEE0E00917584 /* PlayerSettingsViewController.swift in Sources */,
4175E14722080D9300FB7B71 /* IAPHelper.swift in Sources */,
41E34E502138EA8200A3997C /* ImportOperation.swift in Sources */,
41B2A5ED21CCC6D100917584 /* AppNavigationController.swift in Sources */,
41B2AC8E1D43CCE8005382A9 /* ChaptersViewController.swift in Sources */,
@@ -10,6 +10,7 @@ import AVFoundation
import DirectoryWatcher
import MediaPlayer
import Sentry
import SwiftyStoreKit
import UIKit

@UIApplicationMain
@@ -55,6 +56,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.setupDocumentListener()
// load themes if necessary
DataManager.setupDefaultTheme()
// setup store required listeners
self.setupStoreListener()

if let activityDictionary = launchOptions?[.userActivityDictionary] as? [UIApplicationLaunchOptionsKey: Any],
let activityType = activityDictionary[.userActivityType] as? String,
@@ -258,4 +261,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}

func setupStoreListener() {
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
for purchase in purchases {
guard purchase.transaction.transactionState == .purchased
|| purchase.transaction.transactionState == .restored
else { continue }

UserDefaults.standard.set(true, forKey: Constants.UserDefaults.plusUser.rawValue)

if purchase.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
}
}

SwiftyStoreKit.shouldAddStorePaymentHandler = { _, _ in
return true
}
}
}
Oops, something went wrong.

0 comments on commit 7627c63

Please sign in to comment.
You can’t perform that action at this time.