Skip to content

Commit 15d6ef2

Browse files
hyochanclaude
andcommitted
docs: add appAccountToken UUID format requirement
- Add appAccountToken section to StoreKit 2 knowledge base with UUID format requirement, examples, and best practices - Update request.tsx docs to clarify UUID format is required - Update purchase.tsx docs to note null is returned for non-UUID values Closes hyochan/expo-iap#128 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c038688 commit 15d6ef2

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

knowledge/external/storekit2-api.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,63 @@ This document provides external API reference for Apple's StoreKit 2 framework.
2626
- **Introductory offer eligibility**: Override eligibility check with `introductoryOfferEligibility` purchase option
2727
- Both new purchase options are back-deployed to iOS 15
2828

29+
## appAccountToken
30+
31+
A UUID that associates a purchase with a user account in your system. This property allows you to correlate App Store transactions with users in your backend.
32+
33+
### Important: UUID Format Requirement
34+
35+
**The `appAccountToken` must be a valid UUID format.** If you provide a non-UUID string (e.g., `"user-123"` or `"my-account-id"`), Apple's StoreKit will silently return `null` for this field in the transaction response.
36+
37+
#### Valid UUID Examples
38+
39+
```swift
40+
// Valid UUIDs - these will be returned correctly
41+
"550e8400-e29b-41d4-a716-446655440000"
42+
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
43+
UUID().uuidString // Generate new UUID
44+
```
45+
46+
#### Invalid Examples (Will Return null)
47+
48+
```swift
49+
// Invalid - NOT UUID format, Apple returns null silently
50+
"user-123"
51+
"my-account-token"
52+
"abc123"
53+
```
54+
55+
### Usage in Purchase Options
56+
57+
```swift
58+
let appAccountToken = UUID()
59+
let result = try await product.purchase(options: [
60+
.appAccountToken(appAccountToken)
61+
])
62+
```
63+
64+
### Retrieving from Transaction
65+
66+
```swift
67+
let transaction: Transaction
68+
if let token = transaction.appAccountToken {
69+
// Token will only be present if a valid UUID was provided during purchase
70+
print("App Account Token: \(token)")
71+
}
72+
```
73+
74+
### Best Practices
75+
76+
1. **Generate UUIDs per user**: Create and store a UUID for each user in your system
77+
2. **Use consistent tokens**: Use the same UUID for all purchases from the same user
78+
3. **Server-side mapping**: Map the UUID to your internal user ID on your server
79+
4. **Don't use user IDs directly**: Convert your user IDs to UUIDs rather than using them directly
80+
81+
### References
82+
83+
- [Apple Developer Documentation: appAccountToken](https://developer.apple.com/documentation/storekit/transaction/appaccounttoken)
84+
- [GitHub Issue: expo-iap #128](https://github.com/hyochan/expo-iap/issues/128)
85+
2986
## Product
3087

3188
A type that describes an in-app purchase product.

packages/docs/src/pages/docs/types/purchase.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ function TypesPurchase() {
247247
</td>
248248
<td>
249249
Your server's user identifier (UUID you provided at
250-
purchase)
250+
purchase). Only returned if a valid UUID format was
251+
provided during purchase—non-UUID values result in{' '}
252+
<code>null</code>.
251253
</td>
252254
</tr>
253255
<tr>

packages/docs/src/pages/docs/types/request.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,14 @@ await iap.request_purchase(subs_props)`}</CodeBlock>
459459
<td>
460460
<code>appAccountToken</code>
461461
</td>
462-
<td>UUID linking purchase to your server's user</td>
462+
<td>
463+
UUID linking purchase to your server's user.{' '}
464+
<strong>Must be a valid UUID format</strong> (e.g.,{' '}
465+
<code>550e8400-e29b-41d4-a716-446655440000</code>). If a
466+
non-UUID value is provided, Apple will silently return{' '}
467+
<code>null</code> for this field in the purchase
468+
response.
469+
</td>
463470
</tr>
464471
<tr>
465472
<td>

0 commit comments

Comments
 (0)