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.
- package/README.md +71 -162
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,28 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# React Native SDK for Piano.io
|
2
2
|
|
3
|
-
|
4
|
-
[](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
|
-
|
11
|
-
- **Piano
|
12
|
-
- **
|
13
|
-
- **
|
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
|
-
```
|
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
|
-
```
|
49
|
-
//
|
50
|
-
await composer.
|
51
|
-
await composer.
|
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
|
-
//
|
54
|
-
await composer.
|
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
|
-
```
|
66
|
-
|
67
|
-
const result = await composer.executeExperience();
|
68
|
-
|
69
|
-
//
|
70
|
-
|
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
|
-
```
|
76
|
-
// Sign in user
|
58
|
+
```javascript
|
59
|
+
// Sign in a user
|
77
60
|
const user = await composer.signIn();
|
78
61
|
|
79
|
-
// Check
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
162
|
-
- **
|
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
|
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
|
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/
|
200
|
-
|
201
|
-
|
202
|
-
|
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
|
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
|
151
|
+
npx expo run:android
|
224
152
|
|
225
153
|
# Run on iOS
|
226
|
-
npx
|
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
|
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
|
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
|
-
|
173
|
+
Made with ❤️ by HexagonSwiss
|