Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 5716fe6

Browse files
committed
docs: update README with OpenIAP.dev style and comprehensive documentation
- Add centered OpenIAP logo and branding - Include OpenIAP specification introduction and AI coding era context - Restructure with emojis and better visual hierarchy - Add comprehensive feature list with enhanced descriptions - Include OpenIAP ecosystem roadmap table - Add detailed testing instructions with sandbox guidance - Update all code examples to use OpenIap prefixed types - Include community and support links - Match openiap.dev repository styling and structure
1 parent ddf60f8 commit 5716fe6

File tree

1 file changed

+129
-96
lines changed

1 file changed

+129
-96
lines changed

README.md

Lines changed: 129 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
1-
# OpenIAP
1+
# OpenIAP Apple
22

3-
A comprehensive cross-platform In-App Purchase library following the OpenIAP specification. Simplifies the integration of in-app purchases in iOS/macOS/tvOS/watchOS applications with a clean, modern API.
3+
<div align="center">
4+
<img src="https://openiap.dev/logo.png" alt="OpenIAP Logo" width="120" height="120">
5+
</div>
46

5-
## Features
7+
<div align="center">
8+
<strong>A comprehensive Swift implementation of the OpenIAP specification for iOS, macOS, tvOS, and watchOS applications.</strong>
9+
</div>
610

7-
- ✅ StoreKit 2 support (iOS 15+)
8-
- ✅ Legacy StoreKit support (iOS 13-14)
9-
- ✅ Product fetching and caching
10-
- ✅ Purchase handling
11-
- ✅ Receipt validation
12-
- ✅ Subscription management
13-
- ✅ Restore purchases
14-
- ✅ Transaction observation
15-
- ✅ Swift Package Manager support
16-
- ✅ CocoaPods support
11+
<br />
1712

18-
## Requirements
13+
**OpenIAP** is a unified specification for in-app purchases across platforms, frameworks, and emerging technologies. This Apple ecosystem implementation standardizes IAP implementations to reduce fragmentation and enable consistent behavioral across all Apple platforms.
1914

20-
- iOS 13.0+
21-
- macOS 10.15+
22-
- tvOS 13.0+
23-
- watchOS 6.0+
24-
- Swift 5.9+
15+
In the AI coding era, having a unified IAP specification becomes increasingly important as developers build applications across multiple platforms and frameworks with automated tools.
2516

26-
## Installation
17+
## 🌐 Learn More
18+
19+
Visit [**openiap.dev**](https://openiap.dev) for complete documentation, guides, and the full OpenIAP specification.
20+
21+
## ✨ Features
22+
23+
-**StoreKit 2** support with full iOS 15+ compatibility
24+
-**Legacy StoreKit** fallback for iOS 13-14
25+
-**Cross-platform** support (iOS, macOS, tvOS, watchOS)
26+
-**Unified API** following OpenIAP specification
27+
-**Product management** with intelligent caching
28+
-**Purchase handling** with automatic transaction verification
29+
-**Subscription management** and renewal tracking
30+
-**Receipt validation** and transaction security
31+
-**Event-driven** purchase observation
32+
-**Swift Package Manager** and **CocoaPods** support
33+
34+
## 📋 Requirements
35+
36+
| Platform | Minimum Version |
37+
|----------|-----------------|
38+
| iOS | 13.0+ |
39+
| macOS | 10.15+ |
40+
| tvOS | 13.0+ |
41+
| watchOS | 6.0+ |
42+
| Swift | 5.9+ |
43+
44+
## 📦 Installation
2745

2846
### Swift Package Manager
2947

30-
Add the following to your `Package.swift` file:
48+
Add OpenIAP to your `Package.swift`:
3149

3250
```swift
3351
dependencies: [
3452
.package(url: "https://github.com/hyodotdev/openiap-apple.git", from: "1.0.0")
3553
]
3654
```
3755

38-
Or add it through Xcode:
39-
1. File → Add Package Dependencies
40-
2. Enter the repository URL: `https://github.com/hyodotdev/openiap-apple.git`
41-
3. Select the version and add to your target
56+
Or through Xcode:
57+
1. **File****Add Package Dependencies**
58+
2. Enter: `https://github.com/hyodotdev/openiap-apple.git`
59+
3. Select version and add to your target
4260

4361
### CocoaPods
4462

45-
Add the following to your `Podfile`:
63+
Add to your `Podfile`:
4664

4765
```ruby
4866
pod 'openiap', '~> 1.0.0'
@@ -54,24 +72,22 @@ Then run:
5472
pod install
5573
```
5674

57-
## Usage
75+
## 🚀 Quick Start
5876

59-
### Initialize the IAP Manager
77+
### Initialize Connection
6078

6179
```swift
6280
import OpenIAP
6381

64-
// For iOS 15+
65-
if #available(iOS 15.0, *) {
66-
try await IapModule.shared.initConnection()
67-
}
82+
// Initialize the IAP connection
83+
try await OpenIapModule.shared.initConnection()
6884
```
6985

7086
### Fetch Products
7187

7288
```swift
7389
let productIds = ["dev.hyo.premium", "dev.hyo.coins"]
74-
let products = try await IapModule.shared.fetchProducts(skus: productIds)
90+
let products = try await OpenIapModule.shared.fetchProducts(skus: productIds)
7591

7692
for product in products {
7793
print("\(product.title): \(product.displayPrice)")
@@ -82,125 +98,142 @@ for product in products {
8298

8399
```swift
84100
do {
85-
let transaction = try await IapModule.shared.requestPurchase(
101+
let transaction = try await OpenIapModule.shared.requestPurchase(
86102
sku: "dev.hyo.premium",
87103
andDangerouslyFinishTransactionAutomatically: true
88104
)
89-
print("Purchase successful: \(transaction?.transactionIdentifier ?? "")")
105+
print("Purchase successful!")
90106
} catch {
91-
print("Purchase failed: \(error)")
107+
print("Purchase failed: \(error)")
92108
}
93109
```
94110

95-
### Restore Purchases
111+
### Listen to Purchase Events
96112

97113
```swift
98-
let restoredPurchases = try await IapModule.shared.getAvailablePurchases()
99-
print("Restored \(restoredPurchases.count) purchases")
100-
```
101-
102-
### Observe Transactions (Event Listeners)
103-
104-
```swift
105-
// Add purchase updated listener
106-
IapModule.shared.addPurchaseUpdatedListener { purchase in
107-
print("New purchase: \(purchase.productId)")
114+
// Listen for successful purchases
115+
OpenIapModule.shared.addPurchaseUpdatedListener { purchase in
116+
print("🎉 New purchase: \(purchase.productId)")
108117
}
109118

110-
// Add purchase error listener
111-
IapModule.shared.addPurchaseErrorListener { error in
112-
print("Purchase failed: \(error)")
119+
// Handle purchase errors
120+
OpenIapModule.shared.addPurchaseErrorListener { error in
121+
print("💥 Purchase error: \(error.localizedDescription)")
113122
}
114123
```
115124

116-
### Get Purchase History
125+
## 📱 Example App
117126

118-
```swift
119-
let purchases = try await IapModule.shared.getAvailablePurchases()
120-
for purchase in purchases {
121-
print("Product: \(purchase.productId), Date: \(purchase.purchaseTime)")
122-
}
127+
The repository includes a complete **SwiftUI example app** demonstrating all OpenIAP features:
128+
129+
- **Product catalog** with real-time pricing
130+
- **Purchase flow** with loading states and error handling
131+
- **Subscription management** with renewal tracking
132+
- **Purchase history** and transaction details
133+
- **Event logging** for debugging and monitoring
134+
135+
Run the example:
136+
137+
```bash
138+
cd Example
139+
open Martie.xcodeproj
123140
```
124141

125-
### Receipt Validation
142+
## 🧪 Testing
126143

127-
```swift
128-
let receiptData = try await IapModule.shared.getReceiptDataIOS()
129-
print("Receipt data: \(receiptData)")
144+
### Run Tests
145+
146+
```bash
147+
# Via Swift Package Manager
148+
swift test
149+
150+
# Via Xcode
151+
⌘U (Product → Test)
130152
```
131153

132-
## Data Models
154+
### Test with Sandbox
155+
156+
1. Configure your products in **App Store Connect**
157+
2. Create a **Sandbox Apple ID**
158+
3. Use test card: `4242 4242 4242 4242`
159+
4. Monitor purchase events in the Example app logs
133160

134-
### IapProductData
161+
## 📚 Data Models
162+
163+
### OpenIapProductData
135164

136165
```swift
137-
struct IapProductData {
166+
struct OpenIapProductData {
138167
let id: String
139168
let title: String
140169
let description: String
141-
let type: String
170+
let price: Decimal
142171
let displayPrice: String
143-
let price: Double
144-
let currency: String
172+
let type: String
145173
let platform: String
146-
// ... additional properties
147174
}
148175
```
149176

150-
### IapPurchase
177+
### OpenIapPurchase
151178

152179
```swift
153-
struct IapPurchase {
180+
struct OpenIapPurchase {
154181
let productId: String
155182
let transactionId: String
156-
let originalTransactionId: String?
157-
let purchaseTime: Double
158-
let originalPurchaseTime: Double?
159-
let platform: String
183+
let purchaseTime: Date
184+
let purchaseState: PurchaseState
185+
let isAutoRenewing: Bool
186+
187+
// iOS-specific StoreKit 2 properties
188+
let environmentIOS: String?
189+
let storefrontCountryCodeIOS: String?
160190
// ... additional properties
161191
}
162192
```
163193

164-
## Error Handling
194+
## Error Handling
165195

166-
The library provides comprehensive error handling through the `IapError` enum:
196+
OpenIAP provides comprehensive error handling:
167197

168198
```swift
169-
enum IapError: LocalizedError {
199+
enum OpenIapError: LocalizedError {
170200
case purchaseFailed(reason: String)
171201
case purchaseCancelled
172202
case purchaseDeferred
173-
case storeKitError(error: Error)
203+
case productNotFound(productId: String)
174204
case verificationFailed(reason: String)
175-
case unknownError
205+
case storeKitError(error: Error)
176206
case notSupported
177-
// ... additional cases
178207
}
179208
```
180209

181-
## Example App
210+
## 🔗 OpenIAP Ecosystem
182211

183-
Check the `Example` folder for a complete SwiftUI example application demonstrating all features.
212+
| Platform | Repository | Status |
213+
|----------|------------|---------|
214+
| **Specification** | [openiap.dev](https://github.com/hyodotdev/openiap.dev) | ✅ Active |
215+
| **Apple** | [openiap-apple](https://github.com/hyodotdev/openiap-apple) | ✅ Active |
216+
| **React Native** | Coming Soon | 🚧 Planned |
217+
| **Flutter** | Coming Soon | 🚧 Planned |
218+
| **Unity** | Coming Soon | 🚧 Planned |
184219

185-
## Testing
220+
## 🤝 Contributing
186221

187-
Run the tests using:
188-
189-
```bash
190-
swift test
191-
```
192-
193-
Or through Xcode:
194-
1. Product → Test (⌘U)
222+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
195223

196-
## License
224+
## 📄 License
197225

198-
This project is licensed under the MIT License - see the LICENSE file for details.
226+
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
199227

200-
## Contributing
228+
## 💬 Support
201229

202-
Contributions are welcome! Please feel free to submit a Pull Request.
230+
- 📖 **Documentation**: [openiap.dev](https://openiap.dev)
231+
- 🐛 **Bug Reports**: [GitHub Issues](https://github.com/hyodotdev/openiap-apple/issues)
232+
- 💡 **Feature Requests**: [GitHub Discussions](https://github.com/hyodotdev/openiap-apple/discussions)
233+
- 💬 **Community**: [Discord](https://discord.gg/openiap) (Coming Soon)
203234

204-
## Support
235+
---
205236

206-
For issues and feature requests, please use the [GitHub Issues](https://github.com/hyodotdev/openiap-apple/issues) page.
237+
<div align="center">
238+
<strong>Built with ❤️ for the OpenIAP community</strong>
239+
</div>

0 commit comments

Comments
 (0)