|
@@ -32,20 +32,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
|
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
|
|
|
|
|
|
- completeIAPTransactions()
|
|
|
-
|
|
|
- SwiftyStoreKit.updatedDownloadsHandler = { downloads in
|
|
|
-
|
|
|
- let finishedDownloadsCount = downloads.filter { $0.downloadState == .finished }.count
|
|
|
- if finishedDownloadsCount == downloads.count {
|
|
|
- SwiftyStoreKit.finishTransaction(downloads[0].transaction)
|
|
|
- }
|
|
|
- }
|
|
|
+ setupIAP()
|
|
|
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- func completeIAPTransactions() {
|
|
|
+ func setupIAP() {
|
|
|
|
|
|
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
|
|
|
|
|
@@ -65,5 +57,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ SwiftyStoreKit.updatedDownloadsHandler = { downloads in
|
|
|
+
|
|
|
+ // contentURL is not nil if downloadState == .finished
|
|
|
+ let contentURLs = downloads.flatMap { $0.contentURL }
|
|
|
+ if contentURLs.count == downloads.count {
|
|
|
+ print("Saving: \(contentURLs)")
|
|
|
+ SwiftyStoreKit.finishTransaction(downloads[0].transaction)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|