react-native-sdk-pianoio 0.3.4 → 0.3.5

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.
Files changed (2) hide show
  1. package/README.md +71 -162
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,28 +1,13 @@
1
- # 🎹 React Native SDK for Piano.io
1
+ # React Native SDK for Piano.io
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/react-native-sdk-pianoio.svg)](https://www.npmjs.com/package/react-native-sdk-pianoio)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
6
- A React Native SDK for integrating Piano.io's digital monetization platform into your mobile applications. This SDK provides seamless integration with Piano's paywall, subscription, and content monetization features.
3
+ A React Native SDK for integrating Piano.io's digital monetization platform into your mobile applications. This SDK provides seamless, cross-platform integration with Piano's paywall, subscription, and content monetization features.
7
4
 
8
5
  ## ✨ Features
9
6
 
10
- ### 🚀 Core Functionality
11
- - **Piano Composer Integration**: Full integration with Piano's Composer API
12
- - **OAuth Authentication**: User authentication and token management
13
- - **Experience Execution**: Execute Piano experiences with custom configurations
14
- - **Cross-Platform**: Works on both iOS and Android (Android fully implemented)
15
-
16
- ### 📱 Platform Support
17
- - ✅ **Android**: Fully implemented and tested (91% test coverage)
18
- - 🚧 **iOS**: Basic implementation (needs feature parity)
19
-
20
- ### 🔧 Configuration Options
21
- - **Tags Management**: Add/remove tags for content categorization
22
- - **Zone Configuration**: Set zone IDs for targeted experiences
23
- - **Custom Variables**: Add custom data to experiences
24
- - **User Tokens**: Manage user authentication tokens
25
- - **URL Configuration**: Set referrer and target URLs
7
+ - **Full Piano Composer Integration**: Execute experiences, manage content access, and handle paywalls
8
+ - **Piano ID Authentication**: Complete user authentication and token management for both platforms
9
+ - **Cross-Platform Parity**: A single, unified API for both iOS and Android
10
+ - **Flexible Configuration**: Manage tags, zone IDs, custom variables, user tokens, and more
26
11
 
27
12
  ## 📦 Installation
28
13
 
@@ -36,7 +21,7 @@ yarn add react-native-sdk-pianoio
36
21
 
37
22
  ### 1. Initialize the SDK
38
23
 
39
- ```typescript
24
+ ```javascript
40
25
  import { PianoComposer } from 'react-native-sdk-pianoio';
41
26
 
42
27
  // Initialize with your Piano Application ID
@@ -45,44 +30,42 @@ const composer = await PianoComposer.create('YOUR_PIANO_AID');
45
30
 
46
31
  ### 2. Configure the Experience
47
32
 
48
- ```typescript
49
- // Add tags for content categorization
50
- await composer.addTag('premium');
51
- await composer.addTags(['article', 'featured']);
33
+ ```javascript
34
+ // Set the required parameters for the experience
35
+ await composer.setUrl('https://www.your-website.com/premium-article');
36
+ await composer.setZoneId('your_zone_id'); // e.g., 'default'
37
+ await composer.setReferrer('https://www.your-website.com/');
52
38
 
53
- // Set zone ID for targeted experiences
54
- await composer.setZoneId('Zone1');
55
-
56
- // Add custom variables
39
+ // Add optional parameters
40
+ await composer.addTag('premium-content');
57
41
  await composer.setCustomVariable('article_id', '12345');
58
-
59
- // Set user token for authentication
60
- await composer.setUserToken('user_token_123');
61
42
  ```
62
43
 
63
44
  ### 3. Execute the Experience
64
45
 
65
- ```typescript
66
- // Execute with basic configuration
67
- const result = await composer.executeExperience();
68
-
69
- // Execute with advanced configuration
70
- const result = await composer.executeExperienceWithConfig(true, true);
46
+ ```javascript
47
+ try {
48
+ const result = await composer.executeExperience();
49
+ console.log('Experience result:', result);
50
+ // Handle the event data from the Piano backend
51
+ } catch (error) {
52
+ console.error('Failed to execute experience:', error);
53
+ }
71
54
  ```
72
55
 
73
56
  ### 4. Handle Authentication
74
57
 
75
- ```typescript
76
- // Sign in user
58
+ ```javascript
59
+ // Sign in a user
77
60
  const user = await composer.signIn();
78
61
 
79
- // Check authentication status
62
+ // Check if a user is authenticated
80
63
  const isAuthenticated = await composer.isAuthenticated();
81
64
 
82
- // Get current user
65
+ // Get the current user's details
83
66
  const currentUser = await composer.getCurrentUser();
84
67
 
85
- // Sign out user
68
+ // Sign out the user
86
69
  await composer.signOut();
87
70
  ```
88
71
 
@@ -90,95 +73,48 @@ await composer.signOut();
90
73
 
91
74
  ### Core Methods
92
75
 
93
- #### `PianoComposer.create(aid: string)`
94
- Creates and initializes a new PianoComposer instance.
95
-
96
- #### `composer.addTag(tag: string)`
97
- Adds a single tag to the experience.
98
-
99
- #### `composer.addTags(tags: string[])`
100
- Adds multiple tags to the experience.
101
-
102
- #### `composer.setZoneId(zoneId: string)`
103
- Sets the zone ID for targeted experiences.
104
-
105
- #### `composer.setCustomVariable(key: string, value: string)`
106
- Adds a custom variable to the experience.
107
-
108
- #### `composer.executeExperience()`
109
- Executes the Piano experience with current configuration.
110
-
111
- ### Authentication Methods
112
-
113
- #### `composer.signIn()`
114
- Signs in the user with Piano OAuth.
115
-
116
- #### `composer.signOut()`
117
- Signs out the current user.
118
-
119
- #### `composer.getCurrentUser()`
120
- Gets information about the current authenticated user.
121
-
122
- #### `composer.isAuthenticated()`
123
- Checks if a user is currently authenticated.
124
-
125
- ### Advanced Methods
126
-
127
- #### `composer.executeExperienceWithConfig(includeUserData: boolean, debug: boolean)`
128
- Executes experience with advanced configuration options.
129
-
130
- #### `composer.createExperienceRequest(includeUserData?: boolean, debug?: boolean)`
131
- Creates an experience request with custom parameters.
132
-
133
- #### `composer.getStatus()`
134
- Gets the current status of the composer.
135
-
136
- #### `composer.testExecutionFlow()`
137
- Tests the complete execution flow.
138
-
139
- ## 🧪 Testing
140
-
141
- The SDK includes comprehensive test coverage:
142
-
143
- ```bash
144
- # Run all tests
145
- npm test
146
-
147
- # Run tests with coverage
148
- npm run test:coverage
149
-
150
- # Run Android-specific tests
151
- cd android && ./test.sh
152
- ```
153
-
154
- ### Test Results
155
- - ✅ **91% Test Coverage** on Android implementation
156
- - ✅ **67/73 tests passing**
157
- - ✅ **All core functionality tested**
76
+ - `PianoComposer.create(aid: string)` - Creates and initializes a new PianoComposer instance
77
+ - `composer.executeExperience()` - Executes the Piano experience with the current configuration
78
+ - `composer.signIn()` - Initiates the user sign-in flow
79
+ - `composer.signOut()` - Signs out the current user
80
+
81
+ ### Configuration Methods
82
+
83
+ - `addTag(tag: string)`
84
+ - `addTags(tags: string[])`
85
+ - `setZoneId(zoneId: string)`
86
+ - `setReferrer(referrer: string)`
87
+ - `setUrl(url: string)`
88
+ - `setUserToken(token: string)`
89
+ - `addCustomVariable(key: string, value: string)`
90
+ - `setCustomVariables(variables: { [key: string]: string })`
91
+
92
+ ### Utility Methods
93
+
94
+ - `getCurrentUser()`
95
+ - `isAuthenticated()`
96
+ - `getStatus()`
97
+ - `clearConfiguration()`
98
+ - `removeTag(tag: string)`
99
+ - `removeCustomVariable(key: string)`
100
+ - `clearTags()`
101
+ - `clearCustomVariables()`
158
102
 
159
103
  ## 📱 Platform Status
160
104
 
161
- ### Android
162
- - **Status**: Fully implemented and tested
163
- - **Coverage**: 91% test coverage
164
- - **Features**: All core features implemented
165
- - **Dependencies**: React Native 0.78.1 compatible
166
-
167
- ### iOS 🚧
168
- - **Status**: Basic implementation
169
- - **Coverage**: Needs feature parity with Android
170
- - **Features**: Core methods implemented
171
- - **Next Steps**: Implement advanced features and authentication
105
+ - ✅ **Android**: Fully implemented and aligned with the official Piano Android SDK
106
+ - **iOS**: Fully implemented and aligned with the official Piano iOS SDK
172
107
 
173
108
  ## 🔧 Development
174
109
 
175
110
  ### Prerequisites
111
+
176
112
  - Node.js 18+
177
- - React Native 0.78.1
113
+ - React Native
178
114
  - Android Studio (for Android development)
179
- - Xcode (for iOS development)
115
+ - Xcode & CocoaPods (for iOS development)
180
116
 
181
- ### Setup Development Environment
117
+ ### Setup
182
118
 
183
119
  ```bash
184
120
  # Clone the repository
@@ -187,67 +123,44 @@ git clone https://github.com/HexagonSwiss/hex-react-native-sdk-pianoio.git
187
123
  # Install dependencies
188
124
  npm install
189
125
 
190
- # Run tests
191
- npm test
192
-
193
126
  # Build the library
194
127
  npm run build
195
128
  ```
196
129
 
197
130
  ### Project Structure
131
+
198
132
  ```
199
- ├── android/ # Android native implementation
200
- ├── src/main/java/ # Kotlin source files
201
- │ └── src/test/java/ # Android tests
202
- ├── ios/ # iOS native implementation
203
- ├── src/ # TypeScript source
204
- │ ├── index.tsx # Main entry point
205
- │ ├── PianoComposer.tsx # Main SDK class
206
- │ └── NativeSdkPianoio.ts # Native module interface
207
- ├── example/ # Example React Native app
208
- └── lib/ # Built library files
133
+ ├── android/ # Android native implementation
134
+ ├── ios/ # iOS native implementation
135
+ ├── src/ # TypeScript source (JS bridge)
136
+ └── ...
209
137
  ```
210
138
 
211
139
  ## 🎯 Example App
212
140
 
213
- The repository includes a comprehensive example app demonstrating all SDK features:
141
+ The repository includes an example app to demonstrate all SDK features.
214
142
 
215
143
  ```bash
216
- # Navigate to example directory
144
+ # Navigate to the example directory
217
145
  cd example
218
146
 
219
147
  # Install dependencies
220
148
  npm install
221
149
 
222
150
  # Run on Android
223
- npx react-native run-android
151
+ npx expo run:android
224
152
 
225
153
  # Run on iOS
226
- npx react-native run-ios
154
+ npx expo run:ios
227
155
  ```
228
156
 
229
- The example app includes:
230
- - ✅ Basic configuration testing
231
- - ✅ Authentication flow testing
232
- - ✅ Advanced configuration options
233
- - ✅ Experience execution
234
- - ✅ Real-time logging
235
-
236
157
  ## 🤝 Contributing
237
158
 
238
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
239
-
240
- ### Development Workflow
241
- 1. Fork the repository
242
- 2. Create a feature branch
243
- 3. Make your changes
244
- 4. Add tests for new functionality
245
- 5. Ensure all tests pass
246
- 6. Submit a pull request
159
+ We welcome contributions! Please see our Contributing Guide for details.
247
160
 
248
161
  ## 📄 License
249
162
 
250
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
163
+ This project is licensed under the MIT License - see the LICENSE file for details.
251
164
 
252
165
  ## 🆘 Support
253
166
 
@@ -255,10 +168,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
255
168
  - 🐛 **Issues**: [GitHub Issues](https://github.com/HexagonSwiss/hex-react-native-sdk-pianoio/issues)
256
169
  - 📖 **Documentation**: [Piano.io Documentation](https://docs.piano.io/)
257
170
 
258
- ## 🔄 Changelog
259
-
260
- See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
261
-
262
171
  ---
263
172
 
264
- **Made with ❤️ by [HexagonSwiss](https://hexagonswiss.ch)**
173
+ Made with ❤️ by HexagonSwiss
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-sdk-pianoio",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Piano io sdk integration",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",