This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Commit c112ba6
authored
fix(types): add missing discountsIOS and other platform-specific fields (#3046)
## Summary
- Add missing `discountsIOS` field to Product types for iOS subscription
promotional offers
- Add 17 missing iOS-specific Purchase fields (appBundleIdIOS,
environmentIOS, etc.)
- Add missing Android-specific fields (nameAndroid,
oneTimePurchaseOfferDetailsAndroid, developerPayloadAndroid)
- Improve type safety by converting oneTimePurchaseOfferDetailsAndroid
from JSON string to typed object
- Remove all `as any` type assertions throughout type-bridge for better
type safety
- Add global DataModal context to display full purchase data in example
apps
## Changes
### Core Library
**iOS (StoreKit 2)**
- Add discountsIOS field with JSON serialization for promotional offers
- Add 17 iOS Purchase fields: appBundleIdIOS, countryCodeIOS,
currencyCodeIOS, currencySymbolIOS, environmentIOS, expirationDateIOS,
isUpgradedIOS, offerIOS, ownershipTypeIOS, reasonIOS,
reasonStringRepresentationIOS, revocationDateIOS, revocationReasonIOS,
storefrontCountryCodeIOS, subscriptionGroupIdIOS, transactionReasonIOS,
webOrderLineItemIdIOS
- Add offerIOS field with proper JSON serialization
**Android (Play Billing)**
- Add nameAndroid field to Product types
- Add oneTimePurchaseOfferDetailsAndroid with proper typed interface
(NitroOneTimePurchaseOfferDetail)
- Add developerPayloadAndroid to Purchase types
- Convert oneTimePurchaseOfferDetailsAndroid from JSON string to typed
object for better type safety
**Type Safety Improvements**
- Create NitroOneTimePurchaseOfferDetail interface in Nitro spec
- Remove all `as any` type assertions in type-bridge.ts
- Add proper type handling for all new fields
### Example Apps
**Example (React Native)**
- Add DataModalContext for global modal management
- Update AvailablePurchases screen to use global modal
- Add DataModalProvider to App.tsx
- Update tests with renderWithProviders helper
- All tests passing (7 passing, 2 skipped)
**Example-Expo**
- Sync all changes from example project
- Add DataModalContext with identical implementation
- Update copy-screens.sh to handle DataModalContext import path
transformation
- Fix ESLint errors in subscription-flow.tsx:
- Convert Array<T> to T[] syntax
- Add displayName to PlanChangeControls component
- Add missing dependencies to useCallback
## Test Plan
- [x] iOS build successful after changes
- [x] Example app tests passing (7/7)
- [x] Example-expo ESLint checks passing
- [x] TypeScript compilation clean
- [x] Nitro bridge files regenerated successfully
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Global data modal to view/copy JSON (sensitive fields redacted);
provider wired into app and examples.
* Android: show one-time purchase offer details and product name;
preserve developer payload for purchases.
* Purchase flow: storefront display with manual refresh; subscription
flow: plan-change controls and cached purchases.
* **Bug Fixes**
* Expanded iOS/Android purchase & product metadata, improved parsing and
null handling; better purchase error messaging.
* **Refactor**
* Replaced per-screen modals with a shared provider across example apps.
* **Tests**
* Tests updated to render components with the new provider.
* **Chores**
* Script and CI tweaks for example project.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 50b2436 commit c112ba6
17 files changed
Lines changed: 1587 additions & 693 deletions
File tree
- .github/workflows
- android/src/main/java/com/margelo/nitro/iap
- example-expo
- app
- contexts
- scripts
- example
- __tests__/screens
- ios
- screens
- src/contexts
- ios
- src
- specs
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
Lines changed: 36 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
660 | 667 | | |
661 | 668 | | |
662 | 669 | | |
| |||
695 | 702 | | |
696 | 703 | | |
697 | 704 | | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
698 | 711 | | |
699 | 712 | | |
700 | 713 | | |
| |||
708 | 721 | | |
709 | 722 | | |
710 | 723 | | |
| 724 | + | |
711 | 725 | | |
712 | 726 | | |
713 | 727 | | |
714 | 728 | | |
715 | 729 | | |
716 | 730 | | |
717 | 731 | | |
| 732 | + | |
718 | 733 | | |
719 | 734 | | |
720 | 735 | | |
721 | 736 | | |
722 | 737 | | |
723 | 738 | | |
724 | 739 | | |
725 | | - | |
| 740 | + | |
| 741 | + | |
726 | 742 | | |
727 | 743 | | |
728 | 744 | | |
| |||
748 | 764 | | |
749 | 765 | | |
750 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
751 | 784 | | |
752 | 785 | | |
753 | 786 | | |
| |||
756 | 789 | | |
757 | 790 | | |
758 | 791 | | |
759 | | - | |
| 792 | + | |
| 793 | + | |
760 | 794 | | |
761 | 795 | | |
762 | 796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | | - | |
| 16 | + | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
272 | 270 | | |
273 | 271 | | |
274 | 272 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 273 | + | |
281 | 274 | | |
282 | 275 | | |
283 | 276 | | |
| |||
382 | 375 | | |
383 | 376 | | |
384 | 377 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | 378 | | |
474 | 379 | | |
475 | 380 | | |
| |||
0 commit comments