Latest | 1.0.2 |
---|---|
Homepage | https://github.com/Faktorealchik/iOSPurchases |
License | MIT |
Platforms | ios 10.0 |
Authors |
iOSPurchases
help you manage with Apple Subscriptions with your own server. Replacing SwiftyStoreKit.
Prerequisites
- iOS 10.0+
Installing
CocoaPods
iOSPurchases
is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'iOSPurchases'
Getting Started
Code
App Delegate –
import iOSPurchases
in application didFinishLaunchingWithOptions
Purchase.shared.start(key: "YOUR_KEY_IS_HERE", shouldAddStorePayment: { (payment) -> (Bool) in
return true
})
Purchase.shared.serverUrlString = "YOUR SERVER URL HERE"
in application will terminate
Purchase.shared.applicationWillTerminate
Subscribe to notifications, where needed
Purchase.optionsLoadedNotification
Purchase.restoreSuccessfulNotification
Purchase.purchaseSuccessfulNotification
Purchase.filedNotification
Purchase.restoreFailed
Purchase.optionsFailedToLoad
Whenever you want to load your options — just give list of identifiers
Purchase.shared.load(inAppOptions: ["GIVE","HERE","LIST","OF","INAPP","IDENTIFIERS"])
When options loaded, you will recieve a Purchase.optionsLoadedNotification. Then just use
Purchase.shared.options
When user tried to purchase something – use
Purchase.shared.purchase(option: InAppOption)
Restore
Purchase.shared.restore(needVerifyInstantly: Bool = false, verifyingCompletion: ((Response?, Error?) -> ())? = nil)
Response Structure
public struct Response: Decodable {
public let isSubscribed: Bool
public let dateEnd: Int64?
public let serverDate: Int64?
public var date: Date {
return Date(timeIntervalSince1970: Double(dateEnd ?? 0))
}
public var server: Date {
return Date(timeIntervalSince1970: Double(serverDate ?? 0))
}
init(data: Data) throws {
self = try JSONDecoder().decode(Response.self, from: data)
}
}
Check that user is subscribed or verify subscription
Purchase.shared.isSubscribed(completion: @escaping (Bool, Error?) -> ())
Purchase.shared.verify(completion: ((Response?, Error?) -> ())? = nil)
What need to improve
- custom Response struct
- …
License
iOSPurchases
is released under the MIT license.
See LICENSE.md for details.
Latest podspec
{ "name": "iOSPurchases", "version": "1.0.2", "summary": "Purchase framework to buy, restore and verify products", "description": "The best ever framework", "homepage": "https://github.com/Faktorealchik/iOSPurchases", "license": "MIT", "authors": { "nesterov": "[email protected]" }, "platforms": { "ios": "10.0" }, "swift_version": "5.0", "source": { "git": "https://github.com/Faktorealchik/iOSPurchases.git", "tag": "1.0.2" }, "source_files": [ "Classes", "iOSPurchases/Core/**" ], "resource_bundles": { "Purchase": [ "iOSPurchases/Assets/*.*" ] } }
Sun, 02 Jun 2019 10:23:17 +0000