Skip to content

Commit 3092154

Browse files
Document StoreKit 1 vs StoreKit 2 usage in iOS module README (#288)
* Initial plan * docs: document StoreKit 1 vs StoreKit 2 usage in iOS module README Agent-Logs-Url: https://github.com/libgdx/gdx-pay/sessions/83da1d33-2e17-4893-bf7b-606ec8ae02f1 Co-authored-by: keesvandieren <863966+keesvandieren@users.noreply.github.com> * docs: add Kotlin note clarifying no special configuration needed for gdx-pay Agent-Logs-Url: https://github.com/libgdx/gdx-pay/sessions/ee9305f2-2c40-4b1e-9278-a51ba976ced6 Co-authored-by: keesvandieren <863966+keesvandieren@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: keesvandieren <863966+keesvandieren@users.noreply.github.com>
1 parent 4da0ced commit 3092154

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

gdx-pay-iosrobovm-apple/README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,71 @@
11
# InApp purchasing implementation for Apple (iOS/RoboVM)
22

3-
### Dependencies
3+
This module provides two `PurchaseManager` implementations for iOS:
4+
5+
| Implementation | API | Minimum iOS version |
6+
|---|---|---|
7+
| `PurchaseManageriOSApple` | StoreKit 1 | iOS 7+ |
8+
| `PurchaseManageriOSApple2` | StoreKit 2 | iOS 15+ |
9+
10+
## Choosing between StoreKit 1 and StoreKit 2
11+
12+
**StoreKit 2** (`PurchaseManageriOSApple2`) is the recommended implementation for new projects. It uses Apple's modern StoreKit 2 Swift-based API (via [RoboVM StoreKit 2 bindings](https://github.com/MobiVM/robovm-cocoatouch-swift)) and provides:
13+
14+
* Improved subscription handling, including eligibility checks for introductory offers via `isEligibleForIntroOffer()`
15+
* A modern async-based API under the hood
16+
17+
**StoreKit 1** (`PurchaseManageriOSApple`) should be used if your app needs to support iOS versions below 15.
18+
19+
If your app targets a range of iOS versions, you can select the implementation at runtime based on the device's iOS version (see [Instantiation](#instantiation) below).
20+
21+
## Dependencies
422

523
implementation "com.badlogicgames.gdxpay:gdx-pay-iosrobovm-apple:$gdxPayVersion"
624

7-
### Instantiation
25+
This single dependency includes both `PurchaseManageriOSApple` (StoreKit 1) and `PurchaseManageriOSApple2` (StoreKit 2).
26+
27+
The StoreKit 2 implementation depends on the RoboVM StoreKit 2 bindings, which are included as a transitive dependency:
28+
29+
com.mobidevelop.robovm:robopods-swift-storekit2
30+
31+
If your app only uses StoreKit 1 and you want to exclude the StoreKit 2 transitive dependency, you can do so in your Gradle configuration:
32+
33+
implementation("com.badlogicgames.gdxpay:gdx-pay-iosrobovm-apple:$gdxPayVersion") {
34+
exclude group: 'com.mobidevelop.robovm', module: 'robopods-swift-storekit2'
35+
}
36+
37+
### Note for Kotlin users
38+
39+
Both `PurchaseManageriOSApple` and `PurchaseManageriOSApple2` work with Java and Kotlin without any special configuration. All async operations and callbacks are handled internally by the `PurchaseManager` implementation — you interact with it through the standard `PurchaseObserver` interface regardless of your language.
40+
41+
Separately, there is also a Kotlin coroutine wrapper available (`com.mobidevelop.robovm:robopods-swift-storekit2-kt`) for projects that want to use the StoreKit 2 API directly without gdx-pay. This is **not** needed when using gdx-pay.
42+
43+
## Instantiation
44+
45+
### Using StoreKit 1 only
846

947
Add this to your `IOSLauncher`:
1048

1149
game.purchaseManager = new PurchaseManageriOSApple();
1250

51+
### Using StoreKit 2 only
52+
53+
Add this to your `IOSLauncher`:
54+
55+
game.purchaseManager = new PurchaseManageriOSApple2();
56+
57+
### Selecting at runtime based on iOS version
58+
59+
If your app supports both older and newer iOS versions, you can choose the implementation at runtime:
60+
61+
import org.robovm.apple.foundation.Foundation;
62+
63+
if (Foundation.getMajorSystemVersion() >= 15) {
64+
game.purchaseManager = new PurchaseManageriOSApple2();
65+
} else {
66+
game.purchaseManager = new PurchaseManageriOSApple();
67+
}
68+
1369
## Testing
1470
Next to other ways, I find the easiest way to test the IAP the following:
1571

0 commit comments

Comments
 (0)