This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Commit 810a5b8
authored
feat: add renewalInfoIOS for subscription status tracking (#24)
## Summary
Adds `renewalInfoIOS` field to `PurchaseIOS` to support iOS subscription
upgrade/downgrade detection and auto-renewal status tracking using
Apple's StoreKit 2 RenewalInfo API.
## Key Features
- ✅ Detect pending subscription upgrades via `pendingUpgradeProductId`
- ✅ Check auto-renewal status via `willAutoRenew`
- ✅ Get next renewal date via `renewalDate`
- ✅ Identify subscription cancellations
- ✅ Track subscription preferences with `autoRenewPreference`
## Changes
- Added `subscriptionRenewalInfo()` in `StoreKitTypesBridge.swift`
- Updated to `openiap-gql@1.2.0` with RenewalInfoIOS types
- Added unit tests in `OpenIapTests.swift`
- Tested with real Apple Sandbox subscriptions
## Usage Example
```typescript
const purchase = result as PurchaseIOS;
// Detect upgrade
if (purchase.renewalInfoIOS?.pendingUpgradeProductId) {
console.log('Upgrading to:', purchase.renewalInfoIOS.pendingUpgradeProductId);
}
// Detect cancellation
if (purchase.renewalInfoIOS?.willAutoRenew === false) {
console.log('Subscription cancelled');
}
```
## Breaking Changes
None - backwards compatible optional field.
## Related
Provides upgrade/downgrade detection capability
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* New Features
* Purchases now include richer subscription renewal metadata (renewal
status, auto‑renew flag, renewal date, grace period, price‑increase and
pending‑upgrade info).
* Bug Fixes
* More consistent error handling and messaging for external purchase
notices; unexpected or unsupported cases now produce clear error
results.
* Refactor
* Streamlined logging and purchase deduplication with summaries for
inactive subscriptions and clearer transaction traces.
* Tests
* Added coverage for renewal metadata and serialization.
* Chores
* Dependency version updated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 551d86a commit 810a5b8
File tree
6 files changed
+331
-39
lines changed- Sources
- Helpers
- Models
- Tests
6 files changed
+331
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
170 | 281 | | |
171 | 282 | | |
172 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
| |||
456 | 457 | | |
457 | 458 | | |
458 | 459 | | |
| 460 | + | |
| 461 | + | |
459 | 462 | | |
460 | 463 | | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
461 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
462 | 488 | | |
463 | 489 | | |
464 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
271 | 269 | | |
272 | 270 | | |
273 | 271 | | |
| |||
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
290 | | - | |
| 288 | + | |
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
| |||
652 | 650 | | |
653 | 651 | | |
654 | 652 | | |
655 | | - | |
656 | | - | |
657 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
658 | 656 | | |
659 | 657 | | |
660 | 658 | | |
| |||
663 | 661 | | |
664 | 662 | | |
665 | 663 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
670 | 669 | | |
671 | 670 | | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
672 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
673 | 681 | | |
674 | | - | |
| 682 | + | |
675 | 683 | | |
676 | 684 | | |
677 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
175 | 200 | | |
176 | 201 | | |
177 | | - | |
178 | | - | |
179 | 202 | | |
180 | 203 | | |
181 | 204 | | |
| |||
378 | 401 | | |
379 | 402 | | |
380 | 403 | | |
| 404 | + | |
381 | 405 | | |
382 | 406 | | |
383 | 407 | | |
384 | | - | |
385 | 408 | | |
386 | 409 | | |
387 | 410 | | |
388 | 411 | | |
389 | 412 | | |
390 | 413 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 414 | + | |
| 415 | + | |
400 | 416 | | |
401 | | - | |
402 | 417 | | |
403 | 418 | | |
404 | 419 | | |
| |||
407 | 422 | | |
408 | 423 | | |
409 | 424 | | |
410 | | - | |
411 | 425 | | |
412 | 426 | | |
413 | 427 | | |
414 | 428 | | |
415 | | - | |
416 | 429 | | |
| 430 | + | |
417 | 431 | | |
418 | | - | |
| 432 | + | |
419 | 433 | | |
420 | 434 | | |
421 | 435 | | |
422 | 436 | | |
423 | 437 | | |
424 | | - | |
425 | 438 | | |
426 | 439 | | |
427 | | - | |
428 | | - | |
429 | 440 | | |
430 | 441 | | |
431 | | - | |
432 | 442 | | |
433 | 443 | | |
434 | 444 | | |
435 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
436 | 450 | | |
437 | 451 | | |
438 | 452 | | |
| |||
0 commit comments