From 1b5e18d695b1af4e85b8fd73968b905efc9efa11 Mon Sep 17 00:00:00 2001
From: Veronique
Date: Fri, 22 May 2020 11:20:35 +0200
Subject: [PATCH] Update comments and documentation.
---
.jazzy.yaml | 1 -
Documentation/Getting Started.md | 2 +-
Documentation/Getting Started/Installation.md | 19 ++-
.../Getting Started/Micro Example.md | 4 +-
Documentation/License.md | 21 ---
.../Displaying products with purchases.md | 8 +-
Documentation/Usage/Displaying products.md | 4 +-
.../Usage/Displaying subscriptions.md | 10 +-
Documentation/Usage/Purchasing.md | 2 +-
README.md | 140 +++++++----------
.../InAppPurchaseLib/Common/IAPCallback.swift | 22 +++
Sources/InAppPurchaseLib/InAppPurchase.swift | 10 +-
.../InAppPurchaseLib/InAppPurchaseLib.swift | 10 +-
.../InAppPurchaseLib/Product/IAPProduct.swift | 6 +
.../Product/SKProductExtension.swift | 8 +-
docs/API documentation.html | 11 +-
docs/Classes/DefaultPurchaseDelegate.html | 2 +-
docs/Classes/InAppPurchase.html | 5 +-
docs/Enums/IAPErrorCode.html | 2 +-
docs/Enums/IAPPeriodFormat.html | 10 +-
docs/Enums/IAPProductType.html | 12 +-
docs/Enums/IAPPurchaseResultState.html | 2 +-
docs/Enums/IAPRefreshResultState.html | 2 +-
docs/Extensions/SKProduct.html | 4 +-
docs/Getting Started.html | 4 +-
docs/Protocols/IAPErrorProtocol.html | 2 +-
docs/Protocols/IAPPurchaseDelegate.html | 2 +-
docs/Protocols/InAppPurchaseLib.html | 12 +-
docs/Structs/IAPError.html | 2 +-
docs/Structs/IAPProduct.html | 4 +-
docs/Structs/IAPPurchaseResult.html | 17 +-
docs/Structs/IAPRefreshResult.html | 11 +-
docs/Usage.html | 2 +-
docs/analytics.html | 2 +-
docs/badge.svg | 6 +-
docs/displaying-products-with-purchases.html | 10 +-
docs/displaying-products.html | 6 +-
docs/displaying-subscriptions.html | 15 +-
.../Documents/API documentation.html | 11 +-
.../Classes/DefaultPurchaseDelegate.html | 2 +-
.../Documents/Classes/InAppPurchase.html | 5 +-
.../Documents/Enums/IAPErrorCode.html | 2 +-
.../Documents/Enums/IAPPeriodFormat.html | 10 +-
.../Documents/Enums/IAPProductType.html | 12 +-
.../Enums/IAPPurchaseResultState.html | 2 +-
.../Enums/IAPRefreshResultState.html | 2 +-
.../Documents/Extensions/SKProduct.html | 4 +-
.../Resources/Documents/Getting Started.html | 4 +-
.../Documents/Protocols/IAPErrorProtocol.html | 2 +-
.../Protocols/IAPPurchaseDelegate.html | 2 +-
.../Documents/Protocols/InAppPurchaseLib.html | 12 +-
.../Resources/Documents/Structs/IAPError.html | 2 +-
.../Documents/Structs/IAPProduct.html | 4 +-
.../Documents/Structs/IAPPurchaseResult.html | 17 +-
.../Documents/Structs/IAPRefreshResult.html | 11 +-
.../Contents/Resources/Documents/Usage.html | 2 +-
.../Resources/Documents/analytics.html | 2 +-
.../Contents/Resources/Documents/badge.svg | 6 +-
.../displaying-products-with-purchases.html | 10 +-
.../Documents/displaying-products.html | 6 +-
.../Documents/displaying-subscriptions.html | 15 +-
.../Contents/Resources/Documents/errors.html | 2 +-
.../Documents/handling-purchases.html | 2 +-
.../Documents/img/ScreenshotInstallation2.png | Bin 0 -> 81758 bytes
.../Contents/Resources/Documents/index.html | 145 ++++++++----------
.../Resources/Documents/initialization.html | 2 +-
.../Resources/Documents/installation.html | 26 +++-
.../Resources/Documents/micro-example.html | 6 +-
.../Resources/Documents/purchasing.html | 4 +-
.../Resources/Documents/refreshing.html | 2 +-
.../Documents/restoring-purchases.html | 2 +-
.../Contents/Resources/Documents/search.json | 2 +-
.../Documents/server-integration.html | 2 +-
.../Resources/Documents/undocumented.json | 128 +---------------
docs/docsets/InAppPurchaseLib.tgz | Bin 519135 -> 594066 bytes
docs/errors.html | 2 +-
docs/handling-purchases.html | 2 +-
docs/img/ScreenshotInstallation2.png | Bin 0 -> 81758 bytes
docs/index.html | 145 ++++++++----------
docs/initialization.html | 2 +-
docs/installation.html | 26 +++-
docs/micro-example.html | 6 +-
docs/purchasing.html | 4 +-
docs/refreshing.html | 2 +-
docs/restoring-purchases.html | 2 +-
docs/search.json | 2 +-
docs/server-integration.html | 2 +-
docs/undocumented.json | 128 +---------------
img/ScreenshotInstallation2.png | Bin 0 -> 81758 bytes
89 files changed, 491 insertions(+), 712 deletions(-)
delete mode 100644 Documentation/License.md
create mode 100644 docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/img/ScreenshotInstallation2.png
create mode 100644 docs/img/ScreenshotInstallation2.png
create mode 100644 img/ScreenshotInstallation2.png
diff --git a/.jazzy.yaml b/.jazzy.yaml
index a2d6903..45c1c8a 100644
--- a/.jazzy.yaml
+++ b/.jazzy.yaml
@@ -16,7 +16,6 @@ custom_categories:
children:
- "Installation"
- "Micro Example"
- - "License"
- name: "Usage"
children:
- "Initialization"
diff --git a/Documentation/Getting Started.md b/Documentation/Getting Started.md
index 5f64fb2..fa35897 100644
--- a/Documentation/Getting Started.md
+++ b/Documentation/Getting Started.md
@@ -1,6 +1,6 @@
If you haven't already, I highly recommend your read the *Overview* and *Preparing* section of Apple's [In-App Purchase official documentation](https://developer.apple.com/in-app-purchase).
-## Requirements
+# Requirements
* Configure your App and Xcode to support In-App Purchases.
* [AppStore Connect Setup](https://help.apple.com/app-store-connect/#/devb57be10e7)
* Create and configure your [Fovea.Billing](https://billing.fovea.cc/?ref=iap-swift-lib) project account:
diff --git a/Documentation/Getting Started/Installation.md b/Documentation/Getting Started/Installation.md
index 5a88938..6f01bac 100644
--- a/Documentation/Getting Started/Installation.md
+++ b/Documentation/Getting Started/Installation.md
@@ -1,14 +1,21 @@
# Installation
-
-
-
* Select your project in Xcode
* Go to the section *Swift Package*
* Click on *(+) Add Package Dependency*
+
+
+
+
+
* Copy the Git URL: *https://github.com/iridescent-dev/iap-swift-lib.git*
-* Click on *Next* > *Next*
+* Click on *Next*
+* In *Rules* select *Version: Up to Next Major ...*
+* Click on *Next*
+
+
+
+
+
* Make sure your project is selected in *Add to target*
* Click on *Finish*
-
-*Note:* You have to `import InAppPurchaseLib` wherever you use the library.
diff --git a/Documentation/Getting Started/Micro Example.md b/Documentation/Getting Started/Micro Example.md
index 2491fe3..bf4a23a 100644
--- a/Documentation/Getting Started/Micro Example.md
+++ b/Documentation/Getting Started/Micro Example.md
@@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func applicationWillTerminate(_ application: UIApplication) {
- // Clean
+ // Stop library when the application will terminate
InAppPurchase.stop()
}
}
@@ -71,6 +71,7 @@ class ViewController: UIViewController {
}
}
+ // Initiating a purchase
@IBAction func purchase(_ sender: Any) {
self.loaderView.show()
InAppPurchase.purchase(
@@ -80,6 +81,7 @@ class ViewController: UIViewController {
})
}
+ // Restoring purchases
@IBAction func restorePurchases(_ sender: Any) {
self.loaderView.show()
InAppPurchase.restorePurchases(callback: { result in
diff --git a/Documentation/License.md b/Documentation/License.md
deleted file mode 100644
index ce44199..0000000
--- a/Documentation/License.md
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020 Iridescent
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/Documentation/Usage/Displaying products with purchases.md b/Documentation/Usage/Displaying products with purchases.md
index 0ec900c..75c11e7 100644
--- a/Documentation/Usage/Displaying products with purchases.md
+++ b/Documentation/Usage/Displaying products with purchases.md
@@ -1,10 +1,10 @@
# Displaying products with purchases
In your store screen, where you present your products titles and prices with a purchase button, there are some cases to handle that we skipped. Owned products and deferred purchases.
-### Owned products
-Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to `InAppPurchase.hasActivePurchase()` to and to the example later in this section.
+## Owned products
+Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to `InAppPurchase.hasActivePurchase()` to the example later in this section.
-### Deferred purchases
+## Deferred purchases
Apple's **Ask to Buy** feature lets parents approve any purchases initiated by children, including in-app purchases.
With **Ask to Buy** enabled, when a child requests to make a purchase, the app is notified that the purchase is awaiting the parent’s approval in the purchase callback:
@@ -28,7 +28,7 @@ We will use the `hasDeferredTransaction` method:
InAppPurchase.hasDeferredTransaction(for productIdentifier: String) -> Bool
```
-### Example
+## Example
Here's an example that covers what has been discussed above. We will update our example `refreshView` function from before:
``` swift
diff --git a/Documentation/Usage/Displaying products.md b/Documentation/Usage/Displaying products.md
index 83c71b0..07a4233 100644
--- a/Documentation/Usage/Displaying products.md
+++ b/Documentation/Usage/Displaying products.md
@@ -1,13 +1,13 @@
# Displaying products
Let's start with the simplest case: you have a single product.
-You can retrieve all information about this product using the function `InAppPurchase.getProductBy(identifier: "my_product_id")`. This returns an [SKProduct](https://developer.apple.com/documentation/storekit/skproduct) extended with helpful methods.
+You can retrieve all information about this product using the function `InAppPurchase.getProductBy(identifier: "my_product_id")`. This returns an [SKProduct](https://developer.apple.com/documentation/storekit/skproduct) extended with [helpful methods](Extensions/SKProduct.html).
Those are the most important:
- `productIdentifier: String` - The string that identifies the product to the Apple AppStore.
- `localizedTitle: String` - The name of the product, in the language of the device, as retrieved from the AppStore.
- `localizedDescription: String` - A description of the product, in the language of the device, as retrieved from the AppStore.
- - `localizedPrice: String` - The cost of the product in the local currency (_read-only property added by this library_).
+ - `localizedPrice: String` - The cost of the product in the local currency (_read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2_).
*Example*:
diff --git a/Documentation/Usage/Displaying subscriptions.md b/Documentation/Usage/Displaying subscriptions.md
index 0094c2e..46938b2 100644
--- a/Documentation/Usage/Displaying subscriptions.md
+++ b/Documentation/Usage/Displaying subscriptions.md
@@ -1,5 +1,13 @@
# Displaying subscriptions
-For subscription products, you also have some data about subscription periods and introductory offers.
+You can retrieve all information about a product using the function `InAppPurchase.getProductBy(identifier: "my_product_id")`. This returns an [SKProduct](https://developer.apple.com/documentation/storekit/skproduct) extended with [helpful methods](Extensions/SKProduct.html).
+
+Those are the most important:
+- `productIdentifier: String` - The string that identifies the product to the Apple AppStore.
+- `localizedTitle: String` - The name of the product, in the language of the device, as retrieved from the AppStore.
+- `localizedDescription: String` - A description of the product, in the language of the device, as retrieved from the AppStore.
+- `localizedPrice: String` - The cost of the product in the local currency (_read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2_).
+
+For subscription products, you also have some data about subscription periods and introductory offers. (_read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2_)
- `func hasIntroductoryPriceEligible() -> Bool` - The product has an introductory price the user is eligible to.
- `localizedSubscriptionPeriod: String?` - The period of the subscription.
diff --git a/Documentation/Usage/Purchasing.md b/Documentation/Usage/Purchasing.md
index aede98d..2e0853c 100644
--- a/Documentation/Usage/Purchasing.md
+++ b/Documentation/Usage/Purchasing.md
@@ -11,7 +11,7 @@ That is why the process looks like so:
- finalizing transactions when product delivery is complete
- sending purchase request, for which successful doesn't always mean complete
-### Initiating a purchase
+## Initiating a purchase
To initiate a purchase, use the `InAppPurchase.purchase()` function. It takes the `productIdentifier` and a `callback` function, called when the purchase has been processed.
**Important**: Do not process the purchase here, we'll handle that later!
diff --git a/README.md b/README.md
index 0331846..3a3f173 100644
--- a/README.md
+++ b/README.md
@@ -19,104 +19,78 @@
# Getting Started
If you haven't already, I highly recommend your read the *Overview* and *Preparing* section of Apple's [In-App Purchase official documentation](https://developer.apple.com/in-app-purchase).
+## Requirements
+* Configure your App and Xcode to support In-App Purchases.
+ * [AppStore Connect Setup](https://help.apple.com/app-store-connect/#/devb57be10e7)
+* Create and configure your [Fovea.Billing](https://billing.fovea.cc/?ref=iap-swift-lib) project account:
+ * Set your bundle ID
+ * The iOS Shared Secret (or shared key) is to be retrieved from [AppStoreConnect](https://appstoreconnect.apple.com/)
+ * The iOS Subscription Status URL (only if you want subscriptions)
+
## Installation
* Select your project in Xcode
* Go to the section *Swift Package*
* Click on *(+) Add Package Dependency*
* Copy the Git URL: *https://github.com/iridescent-dev/iap-swift-lib.git*
-* Click on *Next* > *Next*
+* Click on *Next*
+* In *Rules* select *Version: Up to Next Major ...*
+* Click on *Next*
* Make sure your project is selected in *Add to target*
* Click on *Finish*
*Note:* You have to `import InAppPurchaseLib` wherever you use the library.
-## Micro Example
-
-```swift
-/** AppDelegate.swift */
-import UIKit
-import InAppPurchaseLib
-
-@UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate {
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- // Initialize the library
- InAppPurchase.initialize(
- iapProducts: [
- IAPProduct(productIdentifier: "my_product", productType: .nonConsumable)
- ],
- validatorUrlString: "https://validator.fovea.cc/v1/validate?appName=demo&apiKey=12345678"
- )
- return true
- }
-
- func applicationWillTerminate(_ application: UIApplication) {
- // clean
- InAppPurchase.stop()
- }
+## Basic Usage
+
+* Initialize the library
+``` swift
+InAppPurchase.initialize(
+ iapProducts: [ IAPProduct(productIdentifier: "my_product", productType: .nonConsumable) ],
+ validatorUrlString: "https://validator.fovea.cc/v1/validate?appName=demo&apiKey=12345678"
+)
+```
+
+* Stop library when the application will terminate
+``` swift
+func applicationWillTerminate(_ application: UIApplication) {
+ InAppPurchase.stop()
}
```
-```swift
-/** ViewController.swift */
-import UIKit
-import StoreKit
-import InAppPurchaseLib
-
-class ViewController: UIViewController {
- private var loaderView = LoaderView()
- @IBOutlet weak var statusLabel: UILabel!
- @IBOutlet weak var productTitleLabel: UILabel!
- @IBOutlet weak var productDescriptionLabel: UILabel!
- @IBOutlet weak var purchaseButton: UIButton!
- @IBOutlet weak var restorePurchasesButton: UIButton!
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Add action for purchases and restore butons.
- purchaseButton.addTarget(self, action: #selector(self.purchase), for: .touchUpInside)
- restorePurchasesButton.addTarget(self, action: #selector(self.restorePurchases), for: .touchUpInside)
- }
-
- override func viewWillAppear(_ animated: Bool) {
- self.refreshView()
- InAppPurchase.refresh(callback: { _ in
- self.refreshView()
- })
- }
-
- func refreshView() {
- guard let product: SKProduct = InAppPurchase.getProductBy(identifier: "my_product") else {
- self.productTitleLabel.text = "Product unavailable"
- return
- }
- // Display product information.
- productTitleLabel.text = product.localizedTitle
- productDescriptionLabel.text = product.localizedDescription
- purchaseButton.setTitle(product.localizedPrice, for: .normal)
-
- // Disable the button if the product has already been purchased.
- if InAppPurchase.hasActivePurchase(for: "my_product") {
- statusLabel.text = "OWNED"
- purchaseButton.isPointerInteractionEnabled = false
- }
- }
-
- @IBAction func purchase(_ sender: Any) {
- self.loaderView.show()
- InAppPurchase.purchase(
- productIdentifier: "my_product",
- callback: { result in
- self.loaderView.hide()
- })
- }
-
- @IBAction func restorePurchases(_ sender: Any) {
- self.loaderView.show()
- InAppPurchase.restorePurchases(callback: { result in
+* Display product information
+``` swift
+guard let product: SKProduct = InAppPurchase.getProductBy(identifier: "my_product") else { return }
+productTitleLabel.text = product.localizedTitle
+productDescriptionLabel.text = product.localizedDescription
+productPriceLabel.text = product.localizedPrice
+```
+
+* Initialize a purchase
+``` swift
+@IBAction func purchase(_ sender: Any) {
+ self.loaderView.show()
+ InAppPurchase.purchase(
+ productIdentifier: "my_product",
+ callback: { result in
self.loaderView.hide()
})
- }
+}
+```
+
+* Unlock purchased content
+``` swift
+if InAppPurchase.hasActivePurchase(for: "my_product") {
+ // display content related to the product
+}
+```
+
+* Restore purchases
+``` swift
+@IBAction func restorePurchases(_ sender: Any) {
+ self.loaderView.show()
+ InAppPurchase.restorePurchases(callback: { result in
+ self.loaderView.hide()
+ })
}
```
diff --git a/Sources/InAppPurchaseLib/Common/IAPCallback.swift b/Sources/InAppPurchaseLib/Common/IAPCallback.swift
index 0e3309b..4b20011 100644
--- a/Sources/InAppPurchaseLib/Common/IAPCallback.swift
+++ b/Sources/InAppPurchaseLib/Common/IAPCallback.swift
@@ -13,10 +13,19 @@ public typealias IAPPurchaseCallback = (IAPPurchaseResult) -> Void
/// The result returned in the `purchase()` callback.
public struct IAPPurchaseResult {
+ /// The result state.
public internal(set) var state: IAPPurchaseResultState
+
+ /// If the state is `failed`, the result can return an `IAPError`.
+ /// The error occurred during the processing of the purchase by the library.
public internal(set) var iapError: IAPError? = nil
+
+ /// If the state is `failed`, the result can return an `SKError`.
+ /// The error occurred during the processing of the purchase by the App Store.
public internal(set) var skError: SKError? = nil
+ /// If there is an error, return the localized description.
+ /// - See also: `IAPError` and `SKError`.
public var localizedDescription: String? {
if skError != nil { return skError!.localizedDescription }
if iapError != nil { return iapError!.localizedDescription }
@@ -28,10 +37,13 @@ public struct IAPPurchaseResult {
public enum IAPPurchaseResultState {
/// The purchase was successful.
case purchased
+
/// Puchase failed.
case failed
+
/// The purchase was cancelled by the user.
case cancelled
+
/// The purchase is deferred.
case deferred
}
@@ -41,9 +53,17 @@ public typealias IAPRefreshCallback = (IAPRefreshResult) -> Void
/// The result returned in the `refresh()` or `restorePurchases()` callback.
public struct IAPRefreshResult {
+ /// The result state.
public internal(set) var state: IAPRefreshResultState
+
+ /// If the state is `failed`, the result can return an `IAPError`.
+ /// The error occurred during the processing of the purchase by the library.
public internal(set) var iapError: IAPError? = nil
+
+ /// If the state is `succeeded`, returns the number of purchases that have been added.
public internal(set) var addedPurchases: Int = 0
+
+ /// If the state is `succeeded`, returns the number of purchases that have been updated.
public internal(set) var updatedPurchases: Int = 0
}
@@ -51,8 +71,10 @@ public struct IAPRefreshResult {
public enum IAPRefreshResultState {
/// Refresh was successful.
case succeeded
+
/// Refresh failed.
case failed
+
/// Refresh has been skipped because it is not necessary.
case skipped
}
diff --git a/Sources/InAppPurchaseLib/InAppPurchase.swift b/Sources/InAppPurchaseLib/InAppPurchase.swift
index caa0efe..5a12f6d 100644
--- a/Sources/InAppPurchaseLib/InAppPurchase.swift
+++ b/Sources/InAppPurchaseLib/InAppPurchase.swift
@@ -8,17 +8,17 @@
import Foundation
import StoreKit
-///
+/// The main class of the library.
public class InAppPurchase: NSObject, InAppPurchaseLib {
- // InAppPurchaseLib version number.
+ /// InAppPurchaseLib version number.
internal static let versionNumber = "1.0.2"
- // The initialize function has been called.
+ /// The initialize function has been called.
internal static var initialized: Bool {
return !iapProducts.isEmpty && iapPurchaseDelegate != nil && validatorUrlString != nil
}
- // Callbacks that are waiting for the refresh.
+ /// Callbacks that are waiting for the refresh.
private static var refreshCallbacks: Array = []
- // The date of the last refresh.
+ /// The date of the last refresh.
private static var lastRefreshDate: Date? = nil
diff --git a/Sources/InAppPurchaseLib/InAppPurchaseLib.swift b/Sources/InAppPurchaseLib/InAppPurchaseLib.swift
index f1bdbf2..d898c40 100644
--- a/Sources/InAppPurchaseLib/InAppPurchaseLib.swift
+++ b/Sources/InAppPurchaseLib/InAppPurchaseLib.swift
@@ -25,7 +25,7 @@ public protocol InAppPurchaseLib {
/// - iapProducts: An array of `IAPProduct`.
/// - validatorUrlString: The validator url retrieved from Fovea.
/// - iapPurchaseDelegate: An instance of class that adopts the `IAPPurchaseDelegate` protocol (default value = `DefaultPurchaseDelegate`).
- /// - applicationUsername: The user name, if your app implements user login.
+ /// - applicationUsername: The user name, if your app implements user login (default value = `nil`).
static func initialize(iapProducts: Array, validatorUrlString: String, iapPurchaseDelegate: IAPPurchaseDelegate, applicationUsername: String?) -> Void
/// Stop observing the payment queue, when the application will terminate, for proper cleanup.
@@ -58,7 +58,7 @@ public protocol InAppPurchaseLib {
/// Request a Payment from the App Store.
/// - Parameters:
/// - productIdentifier: The identifier of the product to purchase.
- /// - quantity: The quantity to purchase (default value = 1).
+ /// - quantity: The quantity to purchase (default value = `1`).
/// - callback: The function that will be called after processing.
/// - See also:`IAPPurchaseResult`
static func purchase(productIdentifier: String, quantity: Int, callback: @escaping IAPPurchaseCallback) -> Void
@@ -104,12 +104,12 @@ public protocol InAppPurchaseLib {
}
public extension InAppPurchaseLib {
- // Sets default `iapPurchaseDelegate` and `applicationUsername`
+ /// Sets `DefaultPurchaseDelegate` as default value for `iapPurchaseDelegate` and `nil` for `applicationUsername`.
static func initialize(iapProducts: Array, validatorUrlString: String, iapPurchaseDelegate: IAPPurchaseDelegate = DefaultPurchaseDelegate(), applicationUsername: String? = nil) {
return initialize(iapProducts: iapProducts, validatorUrlString: validatorUrlString, iapPurchaseDelegate: iapPurchaseDelegate, applicationUsername: applicationUsername)
}
- // Sets 1 as default value for the quantity.
+ /// Sets `1` as default value for the `quantity`.
static func purchase(productIdentifier: String, quantity: Int = 1, callback: @escaping IAPPurchaseCallback) {
return purchase(productIdentifier: productIdentifier, quantity: quantity, callback: callback)
}
@@ -132,7 +132,7 @@ public class DefaultPurchaseDelegate: IAPPurchaseDelegate {
/// Finish the product transactions when a product is newly purchased, updated or restored.
/// - Parameter productIdentifier: The identifier of the product.
- public func productPurchased(productIdentifier: String) {
+ public func productPurchased(productIdentifier: String) -> Void {
InAppPurchase.finishTransactions(for: productIdentifier)
}
}
diff --git a/Sources/InAppPurchaseLib/Product/IAPProduct.swift b/Sources/InAppPurchaseLib/Product/IAPProduct.swift
index 115a87e..d6cbc81 100644
--- a/Sources/InAppPurchaseLib/Product/IAPProduct.swift
+++ b/Sources/InAppPurchaseLib/Product/IAPProduct.swift
@@ -7,6 +7,7 @@
import Foundation
+/// Basic product information used by `InAppPurchase`.
public struct IAPProduct {
/// The identifier of the product.
@@ -27,9 +28,14 @@ public struct IAPProduct {
}
}
+/// Types of in-app purchases.
public enum IAPProductType {
+ /// Consumable in-app purchases are used once, are depleted, and can be purchased again.
case consumable
+ /// Non-consumables are purchased once and do not expire.
case nonConsumable
+ /// This type of subscription does not renew automatically, so users need to renew each time.
case nonRenewingSubscription
+ /// Users are charged on a recurring basis until they decide to cancel.
case autoRenewableSubscription
}
diff --git a/Sources/InAppPurchaseLib/Product/SKProductExtension.swift b/Sources/InAppPurchaseLib/Product/SKProductExtension.swift
index d8c61d2..e51eeb4 100644
--- a/Sources/InAppPurchaseLib/Product/SKProductExtension.swift
+++ b/Sources/InAppPurchaseLib/Product/SKProductExtension.swift
@@ -8,15 +8,21 @@
import Foundation
import StoreKit
-
+/// The format used for the localized subscription periods.
public enum IAPPeriodFormat {
+ /// Remove the number of units if it is equal to 1.
+ /// Ex: if the period is "1 month", the returned period will be "month".
case short
+
+ /// The period will be returned with the number and the unit.
+ /// Ex: "1 month".
case long
}
@available(OSX 10.13.2, *)
@available(iOS 11.2, *)
extension SKProduct {
+ /// The format used for the localized subscription periods.
public static var localizedPeriodFormat: IAPPeriodFormat = .short
/// Checks if the product has an introductory price the user is eligible to.
diff --git a/docs/API documentation.html b/docs/API documentation.html
index 70cd86c..09bdafa 100644
--- a/docs/API documentation.html
+++ b/docs/API documentation.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Errors
-
+
The main class of the library.
+
See more
@@ -316,7 +317,7 @@
Declaration
@@ -344,7 +345,7 @@ Declaration
-
Undocumented
+
Types of in-app purchases.
See more
@@ -399,7 +400,7 @@ Declaration
-
Undocumented
+
The format used for the localized subscription periods.
See more
diff --git a/docs/Classes/DefaultPurchaseDelegate.html b/docs/Classes/DefaultPurchaseDelegate.html
index 5e4025c..838137f 100644
--- a/docs/Classes/DefaultPurchaseDelegate.html
+++ b/docs/Classes/DefaultPurchaseDelegate.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
InAppPurchase
-
+ The main class of the library.
+
diff --git a/docs/Enums/IAPErrorCode.html b/docs/Enums/IAPErrorCode.html
index 16f2456..0e6d852 100644
--- a/docs/Enums/IAPErrorCode.html
+++ b/docs/Enums/IAPErrorCode.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPPeriodFormat
- Undocumented
+ The format used for the localized subscription periods.
@@ -190,7 +190,8 @@ IAPPeriodFormat
-
Undocumented
+
Remove the number of units if it is equal to 1.
+Ex: if the period is “1 month”, the returned period will be “month”.
@@ -217,7 +218,8 @@
Declaration
-
Undocumented
+
The period will be returned with the number and the unit.
+Ex: “1 month”.
diff --git a/docs/Enums/IAPProductType.html b/docs/Enums/IAPProductType.html
index 645973d..4cf7513 100644
--- a/docs/Enums/IAPProductType.html
+++ b/docs/Enums/IAPProductType.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPProductType
- Undocumented
+ Types of in-app purchases.
@@ -190,7 +190,7 @@ IAPProductType
-
Undocumented
+
Consumable in-app purchases are used once, are depleted, and can be purchased again.
@@ -217,7 +217,7 @@
Declaration
-
Undocumented
+
Non-consumables are purchased once and do not expire.
@@ -244,7 +244,7 @@
Declaration
-
Undocumented
+
This type of subscription does not renew automatically, so users need to renew each time.
@@ -271,7 +271,7 @@
Declaration
-
Undocumented
+
Users are charged on a recurring basis until they decide to cancel.
diff --git a/docs/Enums/IAPPurchaseResultState.html b/docs/Enums/IAPPurchaseResultState.html
index 42485c4..5c8ea0a 100644
--- a/docs/Enums/IAPPurchaseResultState.html
+++ b/docs/Enums/IAPPurchaseResultState.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
SKProduct
-
Undocumented
+
The format used for the localized subscription periods.
diff --git a/docs/Getting Started.html b/docs/Getting Started.html
index 717182d..514b505 100644
--- a/docs/Getting Started.html
+++ b/docs/Getting Started.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Getting Started
If you haven’t already, I highly recommend your read the Overview and Preparing section of Apple’s In-App Purchase official documentation.
-
Requirements
+
Requirements
- Configure your App and Xcode to support In-App Purchases.
diff --git a/docs/Protocols/IAPErrorProtocol.html b/docs/Protocols/IAPErrorProtocol.html
index 8c3d780..1ce1550 100644
--- a/docs/Protocols/IAPErrorProtocol.html
+++ b/docs/Protocols/IAPErrorProtocol.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Declaration
Default Implementation
-
+
Sets DefaultPurchaseDelegate
as default value for iapPurchaseDelegate
and nil
for applicationUsername
.
+
Declaration
@@ -364,7 +365,7 @@
Parameters
- The user name, if your app implements user login.
+ The user name, if your app implements user login (default value = nil ).
|
@@ -626,7 +627,8 @@
Return Value
Default Implementation
-
+
Sets 1
as default value for the quantity
.
+
Declaration
@@ -660,7 +662,7 @@
Parameters
- The quantity to purchase (default value = 1).
+ The quantity to purchase (default value = 1 ).
|
diff --git a/docs/Structs/IAPError.html b/docs/Structs/IAPError.html
index 3ce0582..49e575b 100644
--- a/docs/Structs/IAPError.html
+++ b/docs/Structs/IAPError.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPProduct
- Undocumented
+ Basic product information used by InAppPurchase
.
diff --git a/docs/Structs/IAPPurchaseResult.html b/docs/Structs/IAPPurchaseResult.html
index d17b2a6..a84c284 100644
--- a/docs/Structs/IAPPurchaseResult.html
+++ b/docs/Structs/IAPPurchaseResult.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPPurchaseResult
-
Undocumented
+
The result state.
@@ -217,7 +217,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an IAPError
.
+The error occurred during the processing of the purchase by the library.
@@ -244,7 +245,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an SKError
.
+The error occurred during the processing of the purchase by the App Store.
@@ -271,7 +273,12 @@
Declaration
-
Undocumented
+
If there is an error, return the localized description.
+
+
See
+ See also:
IAPError
and
SKError
.
+
+
diff --git a/docs/Structs/IAPRefreshResult.html b/docs/Structs/IAPRefreshResult.html
index 670d0f2..8d51434 100644
--- a/docs/Structs/IAPRefreshResult.html
+++ b/docs/Structs/IAPRefreshResult.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPRefreshResult
-
Undocumented
+
The result state.
@@ -217,7 +217,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an IAPError
.
+The error occurred during the processing of the purchase by the library.
@@ -244,7 +245,7 @@
Declaration
-
Undocumented
+
If the state is succeeded
, returns the number of purchases that have been added.
@@ -271,7 +272,7 @@
Declaration
-
Undocumented
+
If the state is succeeded
, returns the number of purchases that have been updated.
diff --git a/docs/Usage.html b/docs/Usage.html
index 535a067..832c8f7 100644
--- a/docs/Usage.html
+++ b/docs/Usage.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Displaying products with purchases
In your store screen, where you present your products titles and prices with a purchase button, there are some cases to handle that we skipped. Owned products and deferred purchases.
-
Owned products
+
Owned products
-
Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to InAppPurchase.hasActivePurchase()
to and to the example later in this section.
-
Deferred purchases
+
Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to InAppPurchase.hasActivePurchase()
to the example later in this section.
+
Deferred purchases
Apple’s Ask to Buy feature lets parents approve any purchases initiated by children, including in-app purchases.
@@ -187,7 +187,7 @@
Deferred purchases
We will use the hasDeferredTransaction
method:
InAppPurchase.hasDeferredTransaction(for productIdentifier: String) -> Bool
-
Example
+
Example
Here’s an example that covers what has been discussed above. We will update our example refreshView
function from before:
@objc func refreshView() {
diff --git a/docs/displaying-products.html b/docs/displaying-products.html
index cc50b1f..9413128 100644
--- a/docs/displaying-products.html
+++ b/docs/displaying-products.html
@@ -22,7 +22,7 @@
- (77% documented)
+ (95% documented)
Displaying products
Let’s start with the simplest case: you have a single product.
-You can retrieve all information about this product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
+You can retrieve all information about this product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
Those are the most important:
@@ -173,7 +173,7 @@ Displaying products
productIdentifier: String
- The string that identifies the product to the Apple AppStore.
localizedTitle: String
- The name of the product, in the language of the device, as retrieved from the AppStore.
localizedDescription: String
- A description of the product, in the language of the device, as retrieved from the AppStore.
-localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library).
+localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2).
Example:
diff --git a/docs/displaying-subscriptions.html b/docs/displaying-subscriptions.html
index 640c8ff..6d7bbdf 100644
--- a/docs/displaying-subscriptions.html
+++ b/docs/displaying-subscriptions.html
@@ -22,7 +22,7 @@
- (77% documented)
+ (95% documented)
Displaying subscriptions
-For subscription products, you also have some data about subscription periods and introductory offers.
+You can retrieve all information about a product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
+
+Those are the most important:
+
+
+productIdentifier: String
- The string that identifies the product to the Apple AppStore.
+localizedTitle: String
- The name of the product, in the language of the device, as retrieved from the AppStore.
+localizedDescription: String
- A description of the product, in the language of the device, as retrieved from the AppStore.
+localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2).
+
+
+For subscription products, you also have some data about subscription periods and introductory offers. (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2)
func hasIntroductoryPriceEligible() -> Bool
- The product has an introductory price the user is eligible to.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/API documentation.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/API documentation.html
index 70cd86c..09bdafa 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/API documentation.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/API documentation.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Errors
-
+
The main class of the library.
+
See more
@@ -316,7 +317,7 @@
Declaration
@@ -344,7 +345,7 @@ Declaration
-
Undocumented
+
Types of in-app purchases.
See more
@@ -399,7 +400,7 @@ Declaration
-
Undocumented
+
The format used for the localized subscription periods.
See more
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Classes/DefaultPurchaseDelegate.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Classes/DefaultPurchaseDelegate.html
index 5e4025c..838137f 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Classes/DefaultPurchaseDelegate.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Classes/DefaultPurchaseDelegate.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
InAppPurchase
-
+ The main class of the library.
+
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPErrorCode.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPErrorCode.html
index 16f2456..0e6d852 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPErrorCode.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPErrorCode.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPPeriodFormat
- Undocumented
+ The format used for the localized subscription periods.
@@ -190,7 +190,8 @@
IAPPeriodFormat
-
Undocumented
+
Remove the number of units if it is equal to 1.
+Ex: if the period is “1 month”, the returned period will be “month”.
@@ -217,7 +218,8 @@
Declaration
-
Undocumented
+
The period will be returned with the number and the unit.
+Ex: “1 month”.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPProductType.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPProductType.html
index 645973d..4cf7513 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPProductType.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPProductType.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPProductType
- Undocumented
+ Types of in-app purchases.
@@ -190,7 +190,7 @@
IAPProductType
-
Undocumented
+
Consumable in-app purchases are used once, are depleted, and can be purchased again.
@@ -217,7 +217,7 @@
Declaration
-
Undocumented
+
Non-consumables are purchased once and do not expire.
@@ -244,7 +244,7 @@
Declaration
-
Undocumented
+
This type of subscription does not renew automatically, so users need to renew each time.
@@ -271,7 +271,7 @@
Declaration
-
Undocumented
+
Users are charged on a recurring basis until they decide to cancel.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPPurchaseResultState.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPPurchaseResultState.html
index 42485c4..5c8ea0a 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPPurchaseResultState.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Enums/IAPPurchaseResultState.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
SKProduct
-
Undocumented
+
The format used for the localized subscription periods.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Getting Started.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Getting Started.html
index 717182d..514b505 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Getting Started.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Getting Started.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Getting Started
If you haven’t already, I highly recommend your read the Overview and Preparing section of Apple’s In-App Purchase official documentation.
-
Requirements
+
Requirements
- Configure your App and Xcode to support In-App Purchases.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Protocols/IAPErrorProtocol.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Protocols/IAPErrorProtocol.html
index 8c3d780..1ce1550 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Protocols/IAPErrorProtocol.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Protocols/IAPErrorProtocol.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Declaration
Default Implementation
-
+
Sets DefaultPurchaseDelegate
as default value for iapPurchaseDelegate
and nil
for applicationUsername
.
+
Declaration
@@ -364,7 +365,7 @@
Parameters
- The user name, if your app implements user login.
+ The user name, if your app implements user login (default value = nil ).
|
@@ -626,7 +627,8 @@
Return Value
Default Implementation
-
+
Sets 1
as default value for the quantity
.
+
Declaration
@@ -660,7 +662,7 @@
Parameters
- The quantity to purchase (default value = 1).
+ The quantity to purchase (default value = 1 ).
|
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPError.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPError.html
index 3ce0582..49e575b 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPError.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPError.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPProduct
- Undocumented
+ Basic product information used by InAppPurchase
.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPPurchaseResult.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPPurchaseResult.html
index d17b2a6..a84c284 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPPurchaseResult.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPPurchaseResult.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPPurchaseResult
-
Undocumented
+
The result state.
@@ -217,7 +217,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an IAPError
.
+The error occurred during the processing of the purchase by the library.
@@ -244,7 +245,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an SKError
.
+The error occurred during the processing of the purchase by the App Store.
@@ -271,7 +273,12 @@
Declaration
-
Undocumented
+
If there is an error, return the localized description.
+
+
See
+ See also:
IAPError
and
SKError
.
+
+
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPRefreshResult.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPRefreshResult.html
index 670d0f2..8d51434 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPRefreshResult.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Structs/IAPRefreshResult.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
IAPRefreshResult
-
Undocumented
+
The result state.
@@ -217,7 +217,8 @@
Declaration
-
Undocumented
+
If the state is failed
, the result can return an IAPError
.
+The error occurred during the processing of the purchase by the library.
@@ -244,7 +245,7 @@
Declaration
-
Undocumented
+
If the state is succeeded
, returns the number of purchases that have been added.
@@ -271,7 +272,7 @@
Declaration
-
Undocumented
+
If the state is succeeded
, returns the number of purchases that have been updated.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Usage.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Usage.html
index 535a067..832c8f7 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Usage.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/Usage.html
@@ -23,7 +23,7 @@
- (77% documented)
+ (95% documented)
Displaying products with purchases
In your store screen, where you present your products titles and prices with a purchase button, there are some cases to handle that we skipped. Owned products and deferred purchases.
-
Owned products
+
Owned products
-
Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to InAppPurchase.hasActivePurchase()
to and to the example later in this section.
-
Deferred purchases
+
Non-consumables and active auto-renewing subscriptions cannot be purchased again. You should adjust your UI to reflect that state. Refer to InAppPurchase.hasActivePurchase()
to the example later in this section.
+
Deferred purchases
Apple’s Ask to Buy feature lets parents approve any purchases initiated by children, including in-app purchases.
@@ -187,7 +187,7 @@
Deferred purchases
We will use the hasDeferredTransaction
method:
InAppPurchase.hasDeferredTransaction(for productIdentifier: String) -> Bool
-
Example
+
Example
Here’s an example that covers what has been discussed above. We will update our example refreshView
function from before:
@objc func refreshView() {
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-products.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-products.html
index cc50b1f..9413128 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-products.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-products.html
@@ -22,7 +22,7 @@
- (77% documented)
+ (95% documented)
Displaying products
Let’s start with the simplest case: you have a single product.
-You can retrieve all information about this product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
+You can retrieve all information about this product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
Those are the most important:
@@ -173,7 +173,7 @@ Displaying products
productIdentifier: String
- The string that identifies the product to the Apple AppStore.
localizedTitle: String
- The name of the product, in the language of the device, as retrieved from the AppStore.
localizedDescription: String
- A description of the product, in the language of the device, as retrieved from the AppStore.
-localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library).
+localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2).
Example:
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-subscriptions.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-subscriptions.html
index 640c8ff..6d7bbdf 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-subscriptions.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/displaying-subscriptions.html
@@ -22,7 +22,7 @@
- (77% documented)
+ (95% documented)
Displaying subscriptions
-For subscription products, you also have some data about subscription periods and introductory offers.
+You can retrieve all information about a product using the function InAppPurchase.getProductBy(identifier: "my_product_id")
. This returns an SKProduct extended with helpful methods.
+
+Those are the most important:
+
+
+productIdentifier: String
- The string that identifies the product to the Apple AppStore.
+localizedTitle: String
- The name of the product, in the language of the device, as retrieved from the AppStore.
+localizedDescription: String
- A description of the product, in the language of the device, as retrieved from the AppStore.
+localizedPrice: String
- The cost of the product in the local currency (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2).
+
+
+For subscription products, you also have some data about subscription periods and introductory offers. (read-only property added by this library, available for OSX >= 10.13.2 and iOS >= 11.2)
func hasIntroductoryPriceEligible() -> Bool
- The product has an introductory price the user is eligible to.
diff --git a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/errors.html b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/errors.html
index 33fa397..c33344b 100644
--- a/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/errors.html
+++ b/docs/docsets/InAppPurchaseLib.docset/Contents/Resources/Documents/errors.html
@@ -22,7 +22,7 @@
- (77% documented)
+ (95% documented)