expo-iap 2.4.5-rc.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
- <img src="https://github.com/user-attachments/assets/f51a4b1b-b257-47bf-afe7-5ef8692f0594" />
1
+ # Expo IAP
2
2
 
3
- [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
3
+ | In app purchase module in [Expo](https://expo.dev)
4
+
5
+ <div>
6
+ <img src="https://private-user-images.githubusercontent.com/27461460/460432423-3257a1e0-800b-441b-8522-94c35ce751d2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTEyNjQ4NjEsIm5iZiI6MTc1MTI2NDU2MSwicGF0aCI6Ii8yNzQ2MTQ2MC80NjA0MzI0MjMtMzI1N2ExZTAtODAwYi00NDFiLTg1MjItOTRjMzVjZTc1MWQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNjMwVDA2MjI0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlMjFkNmViZmM5NzZmNzZlMmE2OWZjODU4NjczMTM2N2ZkYWVhY2MzMjc5YmIyMDlhNjRkNmEzNWNhMmI3MjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.BdhwkYigGHbjYLJblwUnHYNkX1-jDAWry0MqeLpfKrA" width="400" />
7
+ </div>
4
8
 
5
- In App Purchase module in Expo
9
+ [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
6
10
 
7
11
  # Notice
8
12
 
@@ -13,54 +17,13 @@ The `expo-iap` module has been migrated from [react-native-iap](https://github.c
13
17
  - [Documentation](./docs/IAP.md)
14
18
  - [Error Code Management](./docs/ERROR_CODES.md)
15
19
 
16
- ## Error Handling
17
-
18
- expo-iap now provides a centralized error code system that works consistently across iOS and Android platforms. This system maps platform-specific error codes to standardized TypeScript enums.
19
-
20
- ### Error Codes
20
+ ## Installation
21
21
 
22
- ```typescript
23
- import { ErrorCode } from 'expo-iap';
24
-
25
- // Standardized error codes
26
- ErrorCode.E_USER_CANCELLED // User cancelled the purchase
27
- ErrorCode.E_NETWORK_ERROR // Network connectivity issue
28
- ErrorCode.E_ITEM_UNAVAILABLE // Product not available
29
- ErrorCode.E_SERVICE_ERROR // Store service error
30
- // ... and more
31
- ```
32
-
33
- ### Error Utilities
34
-
35
- ```typescript
36
- import {
37
- mapPlatformError,
38
- isUserCancelledError,
39
- getUserFriendlyErrorMessage
40
- } from 'expo-iap';
41
-
42
- // Handle purchase errors
43
- try {
44
- await requestPurchase({ sku: 'product_id' });
45
- } catch (error) {
46
- if (isUserCancelledError(error)) {
47
- // User cancelled - don't show error
48
- return;
49
- }
50
-
51
- // Show user-friendly message
52
- const message = getUserFriendlyErrorMessage(error);
53
- Alert.alert('Purchase Failed', message);
54
- }
22
+ ```bash
23
+ npx expo install expo-iap
55
24
  ```
56
25
 
57
- ### Platform-Specific Error Mapping
58
-
59
- The system automatically maps platform codes:
60
- - **iOS**: Integer codes (0, 1, 2, etc.) → ErrorCode enum
61
- - **Android**: String codes ("E_USER_CANCELLED", etc.) → ErrorCode enum
62
-
63
- This ensures consistent error handling regardless of platform.
26
+ For detailed usage examples and error handling, see the [documentation](./docs/IAP.md).
64
27
 
65
28
  > Sharing your thoughts—any feedback would be greatly appreciated!
66
29
 
@@ -7,6 +7,7 @@ expo-iap now provides a centralized error code management system that ensures co
7
7
  ## Problem Solved
8
8
 
9
9
  Previously, users experienced inconsistent error codes:
10
+
10
11
  - iOS returned numeric error codes (e.g., "2" for user cancellation)
11
12
  - Android returned string error codes (e.g., "E_USER_CANCELLED" for user cancellation)
12
13
  - The TypeScript enum didn't align with platform-specific implementations
@@ -54,7 +55,7 @@ export const ErrorCodeMapping = {
54
55
  ### Basic Error Handling
55
56
 
56
57
  ```typescript
57
- import { ErrorCode, PurchaseError } from 'expo-iap';
58
+ import {ErrorCode, PurchaseError} from 'expo-iap';
58
59
 
59
60
  // Handle purchase errors consistently
60
61
  const handleError = (error: PurchaseError) => {
@@ -74,7 +75,7 @@ const handleError = (error: PurchaseError) => {
74
75
  ### Creating Errors from Platform Data
75
76
 
76
77
  ```typescript
77
- import { PurchaseError } from 'expo-iap';
78
+ import {PurchaseError} from 'expo-iap';
78
79
 
79
80
  // Create properly typed errors from platform-specific data
80
81
  const error = PurchaseError.fromPlatformError(rawErrorData, 'ios');
@@ -83,18 +84,24 @@ const error = PurchaseError.fromPlatformError(rawErrorData, 'ios');
83
84
  ### Error Code Utilities
84
85
 
85
86
  ```typescript
86
- import { ErrorCodeUtils, ErrorCode } from 'expo-iap';
87
+ import {ErrorCodeUtils, ErrorCode} from 'expo-iap';
87
88
 
88
89
  // Convert platform-specific codes to standard enum
89
- const errorCode = ErrorCodeUtils.fromPlatformCode(2, 'ios');
90
+ const errorCode = ErrorCodeUtils.fromPlatformCode(2, 'ios');
90
91
  // Returns ErrorCode.E_USER_CANCELLED
91
92
 
92
- // Convert standard enum to platform-specific code
93
- const iosCode = ErrorCodeUtils.toPlatformCode(ErrorCode.E_USER_CANCELLED, 'ios');
93
+ // Convert standard enum to platform-specific code
94
+ const iosCode = ErrorCodeUtils.toPlatformCode(
95
+ ErrorCode.E_USER_CANCELLED,
96
+ 'ios',
97
+ );
94
98
  // Returns 2
95
99
 
96
100
  // Check platform support
97
- const isSupported = ErrorCodeUtils.isValidForPlatform(ErrorCode.E_USER_CANCELLED, 'ios');
101
+ const isSupported = ErrorCodeUtils.isValidForPlatform(
102
+ ErrorCode.E_USER_CANCELLED,
103
+ 'ios',
104
+ );
98
105
  // Returns true
99
106
  ```
100
107
 
@@ -108,7 +115,7 @@ if (error.code === '2') {
108
115
  // Handle user cancellation
109
116
  }
110
117
 
111
- // Android would return string codes
118
+ // Android would return string codes
112
119
  if (error.code === 'E_USER_CANCELLED') {
113
120
  // Handle user cancellation
114
121
  }
@@ -117,7 +124,7 @@ if (error.code === 'E_USER_CANCELLED') {
117
124
  ### After (Consistent)
118
125
 
119
126
  ```typescript
120
- import { ErrorCode } from 'expo-iap';
127
+ import {ErrorCode} from 'expo-iap';
121
128
 
122
129
  // Works consistently across platforms
123
130
  if (error.code === ErrorCode.E_USER_CANCELLED) {
@@ -157,6 +164,7 @@ if (error.code === ErrorCode.E_USER_CANCELLED) {
157
164
  ## Breaking Changes
158
165
 
159
166
  This is a **non-breaking change** for most users:
167
+
160
168
  - Existing error handling will continue to work
161
169
  - New error code system provides additional functionality
162
170
  - Users can migrate gradually to the new system
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.4.5-rc.1",
3
+ "version": "2.5.0",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -49,5 +49,8 @@
49
49
  "expo": "*",
50
50
  "react": "*",
51
51
  "react-native": "*"
52
+ },
53
+ "expo": {
54
+ "plugin": "./app.plugin.js"
52
55
  }
53
56
  }
@@ -1 +1 @@
1
- {"root":["./src/withiap.ts"],"version":"5.8.3"}
1
+ {"root":["./src/withIAP.ts"],"version":"5.8.3"}
package/docs/README.md DELETED
@@ -1,30 +0,0 @@
1
- # Documentation
2
-
3
- This directory contains detailed documentation for expo-iap.
4
-
5
- ## Available Documents
6
-
7
- - **[API Documentation](./IAP.md)** - Complete API reference and usage examples
8
- - **[Error Code Management](./ERROR_CODES.md)** - Centralized error handling system documentation
9
-
10
- ## Quick Links
11
-
12
- - [Main README](../README.md) - Project overview and quick start
13
- - [Example App](../example/) - Sample implementation
14
- - [GitHub Issues](https://github.com/hyochan/expo-iap/issues) - Bug reports and feature requests
15
-
16
- ## Contributing
17
-
18
- If you find any documentation errors or have suggestions for improvements, please:
19
-
20
- 1. Check existing [issues](https://github.com/hyochan/expo-iap/issues)
21
- 2. Create a new issue with the `documentation` label
22
- 3. Submit a pull request with your improvements
23
-
24
- ## Support
25
-
26
- For questions and support:
27
-
28
- - 📚 Read the documentation in this folder
29
- - 🐛 Report bugs via [GitHub Issues](https://github.com/hyochan/expo-iap/issues)
30
- - 💬 Join discussions in [GitHub Discussions](https://github.com/hyochan/expo-iap/discussions)