File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Sources/StoreKitPlus/Products Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 5
5
// Created by Daniel Saidi on 2024-12-04.
6
6
//
7
7
8
- import SwiftUI
8
+ import StoreKit
9
9
10
+ /// This struct is a basic prroduct representation, that you
11
+ /// can use to define your products with just an ID and name.
12
+ ///
13
+ /// The ``StoreContext`` is extended with more ways to fetch
14
+ /// product information for a basic product.
10
15
public struct BasicProduct : Identifiable , ProductRepresentable {
11
16
12
- /// Create a new product.
17
+ /// Create a basic product representation .
13
18
///
14
19
/// - Parameters:
15
20
/// - id: The App Store string ID of the product.
@@ -26,6 +31,19 @@ public struct BasicProduct: Identifiable, ProductRepresentable {
26
31
public let name : String
27
32
}
28
33
34
+ public extension StoreContext {
35
+
36
+ /// Whether a certain basic product is purchased.
37
+ func isProductPurchased( _ prod: BasicProduct ) -> Bool {
38
+ isProductPurchased ( id: prod. id)
39
+ }
40
+
41
+ /// Get a StoreKit product for a certain basic product.
42
+ func product( _ prod: BasicProduct ) -> Product ? {
43
+ product ( withId: prod. id)
44
+ }
45
+ }
46
+
29
47
public extension BasicProduct {
30
48
31
49
static func preview( _ name: String ) -> Self {
You can’t perform that action at this time.
0 commit comments