Commit 6a38465
authored
Fix connection lifecycle and undefined method issues (#518)
## Summary
This PR fixes critical issues with IAP connection lifecycle management
and undefined method errors in the Flutter InApp Purchase plugin.
### Changes
1. **Fix undefined method error in getAvailablePurchases**
- Replace direct method calls with proper channel invocations
- Fix getAvailableItemsByType calls for Android platform
- Use extractPurchased helper to process results correctly
2. **Fix connection check in subscription flow screen**
- Change connection result comparison from string to boolean
- Match the pattern used in purchase flow screen
- Resolves "Not connected" issue in subscription flow
3. **Add proper connection lifecycle management**
- Add endConnection calls to dispose methods in all screens
- Ensure connections are properly closed when leaving screens
- Prevent connection issues when re-entering screens
4. **Remove hook and provider implementations**
- Completely remove use_iap hook implementation
- Remove IapProvider from the example app
- Simplify API to use direct FlutterInappPurchase.instance calls
- Remove flutter_hooks dependency from example app and main package
5. **Update to version 6.0.0-rc.4**
- Add new errors and events modules for better error handling
- Update example app with improved screen structure
- Clean up deprecated methods and imports
- Restructure documentation to align with simplified API
## Breaking Changes
- Removed useIap hook - use FlutterInappPurchase.instance directly
instead
- Removed IapProvider - no longer needed with simplified API
- Removed flutter_hooks dependency
## Test Plan
- [x] Test purchase flow screen - connections properly initialized and
closed
- [x] Test subscription flow screen - connections properly initialized
and closed
- [x] Test available purchases screen - connections properly initialized
and closed
- [x] Verify no connection issues when navigating between screens
- [x] Confirm purchases and subscriptions work correctly on both iOS and
Android
- [x] Verify all screens work without hooks/provider
## Related Issues
Fixes connection lifecycle issues reported in the example app where
screens would show "Not connected" after navigating back and forth.1 parent d8c8b8b commit 6a38465
File tree
38 files changed
+4121
-6742
lines changed- android/src/main/kotlin/dev/hyo/flutterinapppurchase
- docs
- docs
- api
- getting-started
- guides
- example
- lib
- src
- screens
- lib
- utils
- test
38 files changed
+4121
-6742
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | | - | |
| 10 | + | |
6 | 11 | | |
7 | | - | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
| |||
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
17 | | - | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| 27 | + | |
| 28 | + | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | | - | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | | - | |
| 39 | + | |
30 | 40 | | |
31 | 41 | | |
32 | | - | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
41 | 75 | | |
42 | 76 | | |
43 | 77 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
| |||
Lines changed: 38 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
165 | | - | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
| |||
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
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 | 218 | | |
263 | 219 | | |
264 | 220 | | |
| |||
618 | 574 | | |
619 | 575 | | |
620 | 576 | | |
| 577 | + | |
621 | 578 | | |
| 579 | + | |
622 | 580 | | |
623 | 581 | | |
624 | 582 | | |
| |||
631 | 589 | | |
632 | 590 | | |
633 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
634 | 596 | | |
635 | 597 | | |
| 598 | + | |
636 | 599 | | |
637 | 600 | | |
638 | 601 | | |
639 | 602 | | |
640 | 603 | | |
641 | 604 | | |
642 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
643 | 613 | | |
644 | 614 | | |
645 | 615 | | |
| 616 | + | |
646 | 617 | | |
| 618 | + | |
647 | 619 | | |
648 | 620 | | |
649 | 621 | | |
| |||
662 | 634 | | |
663 | 635 | | |
664 | 636 | | |
665 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
666 | 645 | | |
667 | 646 | | |
668 | 647 | | |
| |||
672 | 651 | | |
673 | 652 | | |
674 | 653 | | |
675 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
676 | 662 | | |
677 | 663 | | |
678 | 664 | | |
679 | | - | |
| 665 | + | |
680 | 666 | | |
681 | 667 | | |
682 | 668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
45 | 63 | | |
46 | 64 | | |
47 | 65 | | |
48 | 66 | | |
49 | | - | |
50 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
51 | 70 | | |
52 | 71 | | |
53 | 72 | | |
54 | | - | |
| 73 | + | |
55 | 74 | | |
56 | | - | |
57 | | - | |
| 75 | + | |
| 76 | + | |
58 | 77 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 78 | + | |
62 | 79 | | |
63 | 80 | | |
64 | 81 | | |
65 | | - | |
| 82 | + | |
66 | 83 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 84 | + | |
70 | 85 | | |
71 | 86 | | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
75 | | - | |
| 90 | + | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
| |||
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | | - | |
| 101 | + | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
| |||
0 commit comments