You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2026. It is now read-only.
fix: reset listener state on endConnection for proper reconnection (#3151)
## Summary
- Reset `listenersAttached` flag (Android) and `isInitializing` flag
(iOS) during `endConnection` so listeners can be re-registered after
reconnection
- Add tests verifying purchase and error listeners work correctly after
`endConnection → initConnection` cycle
## Changes
### Android (`HybridRnIap.kt`)
- Reset `listenersAttached = false` in `endConnection` to allow
re-attachment on next `initConnection`
### iOS (`HybridRnIap.swift`)
- Reset `isInitializing = false` in `endConnection` to allow
re-initialization
- Clean up extra blank lines
### Tests (`index.test.ts`)
- Add reconnection test: purchase updated listeners work after
`endConnection → initConnection`
- Add reconnection test: error listeners work after `endConnection →
initConnection`
## Test plan
- [x] `yarn typecheck` passes
- [x] `yarn lint` passes
- [x] `yarn test` passes (new reconnection tests included)
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Clarified Hook API semantics: removed certain examples, added guidance
that purchase results arrive via callbacks (onPurchaseSuccess), and
adjusted header formatting.
* **Bug Fixes**
* Improved connection cleanup to fully reset listeners and
initialization state for reliable reconnection.
* **Breaking Changes**
* requestPurchase now returns Promise<void>; purchase results are
delivered via callbacks.
* **Tests**
* Added reconnection and purchase-request tests verifying listeners and
void return behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
- Inside the `useIAP` hook, most methods return `Promise<void>` and update internal state. Do not design examples that expect returned data from these methods.
- The root (index) API is value-returning and can be awaited to receive data directly. Use root API when not using React state.
259
+
- Example: `const result = await requestPurchase({...})` returns `Promise<RequestPurchaseResult | null>` (though native returns empty array by design - actual results come through event listeners).
258
260
259
261
### Common CI Fixes
260
262
@@ -297,7 +299,7 @@ The project uses a centralized error handling approach across all platforms:
297
299
-`getUserFriendlyErrorMessage()` - **Public helper** - Get user-friendly error messages
298
300
-`ErrorCode` enum (from types.ts) - Standardized error codes across platforms
299
301
300
-
**Android & iOS (OpenIAP)**
302
+
### Android & iOS (OpenIAP)
301
303
302
304
Both platforms use the OpenIAP library's error handling:
0 commit comments