nimbbl-mobile-react-native-sdk 1.0.0 → 1.1.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
@@ -36,8 +36,9 @@ The Nimbbl React Native SDK is compatible with the following npm versions:
36
36
  | `^1.0.0-alpha.0` | ✅ Supported | Initial alpha release |
37
37
  | `^1.0.0-alpha.1` | ✅ Supported | Bug fixes and improvements |
38
38
  | `^1.0.0-alpha.2` | ✅ Supported | Enhanced error handling |
39
- | `^1.0.0-alpha.3` | ✅ Supported | Latest alpha release |
40
- | `^1.0.0` | 🔄 Coming Soon | Stable release |
39
+ | `^1.0.0-alpha.3` | ✅ Supported | Enhanced error handling |
40
+ | `^1.0.0-alpha.12` | Supported | Latest alpha release |
41
+ | `^1.0.0` | ✅ **Current Stable** | **Production ready** |
41
42
  | `^1.1.0` | 🔄 Coming Soon | Feature updates |
42
43
  | `^2.0.0` | 🔄 Coming Soon | Major version with breaking changes |
43
44
 
@@ -125,7 +126,7 @@ const checkoutResult = await nimbblSDK.checkout({
125
126
 
126
127
  ### 3. Handle Payment Status
127
128
 
128
- The SDK automatically handles payment status through event listeners. You don't need to manually check status.
129
+ The SDK automatically manages event listeners and handles payment status updates. You don't need to manually add or remove event listeners - the SDK handles this internally for optimal performance.
129
130
 
130
131
  ## API Reference
131
132
 
@@ -136,21 +137,28 @@ The main SDK class that provides all payment functionality.
136
137
  #### Methods
137
138
 
138
139
  - `getSharedInstance()` - Get shared SDK instance (singleton pattern)
139
- - `initialize(config)` - Initialize the SDK with configuration
140
+ - `initialize(config)` - Initialize the SDK with configuration and auto-setup event listeners
140
141
  - `checkout(options)` - Process payment with order token
141
142
  - `testNativeModule()` - Test native module availability
142
- - `addEventListener(eventName, callback)` - Add event listener
143
+ - `addEventListener(eventName, callback)` - Add event listener (SDK manages lifecycle automatically)
143
144
  - `removeEventListener(eventName, callback)` - Remove event listener
144
145
  - `removeAllEventListeners()` - Remove all event listeners
145
146
 
146
147
  ### Event Handling
147
148
 
149
+ The SDK automatically manages event listeners for optimal performance. Event listeners are automatically set up during initialization and cleaned up when needed.
150
+
148
151
  ```javascript
149
152
  import { NimbblSDK, EVENTS } from 'nimbbl-mobile-react-native-sdk';
150
153
 
151
154
  const nimbblSDK = NimbblSDK.getSharedInstance();
152
155
 
153
- // Listen for payment events
156
+ // Initialize SDK (automatically sets up event listeners)
157
+ await nimbblSDK.initialize({
158
+ environment: 'sandbox'
159
+ });
160
+
161
+ // Listen for payment events (SDK manages listener lifecycle)
154
162
  nimbblSDK.addEventListener(EVENTS.PAYMENT_SUCCESS, (data) => {
155
163
  console.log('Payment successful:', data);
156
164
  // Handle success - navigate to success screen
@@ -160,6 +168,9 @@ nimbblSDK.addEventListener(EVENTS.PAYMENT_FAILED, (data) => {
160
168
  console.log('Payment failed:', data);
161
169
  // Handle failure - show error message
162
170
  });
171
+
172
+ // Optional: Clean up listeners when done (SDK also handles this automatically)
173
+ // nimbblSDK.removeAllEventListeners();
163
174
  ```
164
175
 
165
176
  ## Configuration
@@ -271,6 +282,8 @@ class PaymentManager {
271
282
  }
272
283
 
273
284
  setupEventListeners() {
285
+ // Event listeners are automatically managed by the SDK
286
+ // You can add custom listeners for your app's specific needs
274
287
  this.nimbblSDK.addEventListener(EVENTS.PAYMENT_SUCCESS, (data) => {
275
288
  console.log('Payment successful:', data);
276
289
  // Navigate to success screen
@@ -305,6 +318,88 @@ class PaymentManager {
305
318
 
306
319
 
307
320
 
321
+ ## Troubleshooting
322
+
323
+ ### Common Issues
324
+
325
+ #### 1. Payment Status Screen Not Opening (iOS)
326
+
327
+ **Problem**: WebView opens and closes, but payment status screen doesn't appear.
328
+
329
+ **Solution**:
330
+ - Ensure you're using the latest SDK version (`^1.0.0`)
331
+ - The SDK automatically manages event listeners - no manual setup required
332
+ - Check that your app properly handles the payment success/failure events
333
+
334
+ #### 2. Event Listeners Not Working
335
+
336
+ **Problem**: Payment events are not being received.
337
+
338
+ **Solution**:
339
+ - The SDK automatically sets up event listeners during initialization
340
+ - Make sure to call `initialize()` before using the SDK
341
+ - Event listeners are managed internally for optimal performance
342
+
343
+ #### 3. iOS Build Issues
344
+
345
+ **Problem**: Build fails with missing native modules.
346
+
347
+ **Solution**:
348
+ ```bash
349
+ cd ios
350
+ rm -rf build
351
+ rm -rf ~/Library/Developer/Xcode/DerivedData/*
352
+ pod install
353
+ cd ..
354
+ npx react-native run-ios
355
+ ```
356
+
357
+ #### 4. Android Build Issues
358
+
359
+ **Problem**: Build fails with Gradle errors.
360
+
361
+ **Solution**:
362
+ ```bash
363
+ cd android
364
+ ./gradlew clean
365
+ cd ..
366
+ npx react-native run-android
367
+ ```
368
+
369
+ #### 5. Metro Bundler Issues
370
+
371
+ **Problem**: JavaScript bundle fails to load.
372
+
373
+ **Solution**:
374
+ ```bash
375
+ npx react-native start --reset-cache
376
+ ```
377
+
378
+ ### Debug Mode
379
+
380
+ For debugging purposes, you can check the SDK initialization status and handle errors appropriately:
381
+
382
+ ```javascript
383
+ const nimbblSDK = NimbblSDK.getSharedInstance();
384
+
385
+ try {
386
+ await nimbblSDK.initialize({
387
+ environment: 'sandbox'
388
+ });
389
+ console.log('SDK initialized successfully');
390
+ } catch (error) {
391
+ console.error('SDK initialization failed:', error);
392
+ }
393
+ ```
394
+
395
+ ### Getting Help
396
+
397
+ If you encounter issues not covered here:
398
+
399
+ 1. Check the [sample app](https://github.com/nimbbl-tech/nimbbl_react_native_sample_app) for implementation examples
400
+ 2. Review the [API documentation](#api-reference) above
401
+ 3. Contact support at support@nimbbl.biz
402
+
308
403
  ## License
309
404
 
310
405
  This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
@@ -332,17 +427,23 @@ npm install nimbbl-mobile-react-native-sdk@1.0.0-alpha.3
332
427
 
333
428
  ### Migration from Alpha to Stable
334
429
 
335
- When the stable version is released:
430
+ **✅ Stable version is now available!**
336
431
 
337
432
  ```bash
338
433
  # Upgrade from alpha to stable
339
434
  npm install nimbbl-mobile-react-native-sdk@^1.0.0
340
435
 
341
436
  # Update your package.json
342
- # Change from: "nimbbl-mobile-react-native-sdk": "^1.0.0-alpha.3"
437
+ # Change from: "nimbbl-mobile-react-native-sdk": "^1.0.0-alpha.12"
343
438
  # To: "nimbbl-mobile-react-native-sdk": "^1.0.0"
344
439
  ```
345
440
 
441
+ **Key Changes in v1.0.0:**
442
+ - ✅ **Automatic Event Listener Management**: SDK now automatically manages event listeners for optimal performance
443
+ - ✅ **Simplified Integration**: No need to manually add/remove event listeners
444
+ - ✅ **Enhanced Error Handling**: Improved error messages and debugging capabilities
445
+ - ✅ **Production Ready**: Fully tested and optimized for production use
446
+
346
447
  ### Breaking Changes Migration
347
448
 
348
449
  For major version updates (e.g., 1.x to 2.x):
@@ -371,4 +472,46 @@ For production applications, consider locking to specific versions:
371
472
 
372
473
  ## Changelog
373
474
 
374
- *This section will be updated with future releases.*
475
+ ### v1.0.0 (Current Stable Release)
476
+
477
+ **🎉 First Stable Release - Production Ready!**
478
+
479
+ #### ✨ New Features
480
+ - **Automatic Event Listener Management**: SDK now automatically manages event listeners for optimal performance
481
+ - **Simplified Integration**: No need to manually add/remove event listeners
482
+ - **Enhanced Error Handling**: Improved error messages and debugging capabilities
483
+
484
+ #### 🔧 Improvements
485
+ - **Performance Optimization**: Better memory management and event handling
486
+ - **Code Quality**: Comprehensive TypeScript definitions and error handling
487
+ - **Documentation**: Complete API documentation with examples and troubleshooting
488
+
489
+ #### 🐛 Bug Fixes
490
+ - Fixed iOS payment status screen not opening issue
491
+ - Resolved event listener lifecycle management
492
+ - Improved WebView integration stability
493
+
494
+ #### 📦 Dependencies
495
+ - Updated to latest React Native 0.76.0 compatibility
496
+ - Enhanced iOS and Android native module integration
497
+
498
+ ---
499
+
500
+ ### Previous Alpha Releases
501
+
502
+ #### v1.0.0-alpha.12
503
+ - Enhanced event listener management
504
+ - Improved iOS native module integration
505
+ - Added debug logging capabilities
506
+
507
+ #### v1.0.0-alpha.3
508
+ - Enhanced error handling
509
+ - Improved WebView integration
510
+ - Better TypeScript support
511
+
512
+ #### v1.0.0-alpha.2
513
+ - Bug fixes and improvements
514
+ - Enhanced error handling
515
+
516
+ #### v1.0.0-alpha.1
517
+ - Initial alpha release with core functionality
@@ -8,6 +8,7 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
8
8
 
9
9
  private var config: [String: Any] = [:]
10
10
  private var isInitialized = false
11
+ private var hasListeners = false
11
12
 
12
13
  override init() {
13
14
  super.init()
@@ -33,6 +34,14 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
33
34
  return false
34
35
  }
35
36
 
37
+ override func startObserving() {
38
+ hasListeners = true
39
+ }
40
+
41
+ override func stopObserving() {
42
+ hasListeners = false
43
+ }
44
+
36
45
  @objc
37
46
  func testModule(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
38
47
  // print("NimbblReactNativeSDK testModule called")
@@ -189,11 +198,15 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
189
198
 
190
199
  func onPaymentSuccess(_ response: [AnyHashable : Any]) {
191
200
  // print("Payment success received with response: \(response)")
192
- sendEvent(withName: "payment_success", body: response)
201
+ if hasListeners {
202
+ sendEvent(withName: "payment_success", body: response)
203
+ }
193
204
  }
194
205
 
195
206
  func onError(_ error: [AnyHashable : Any]) {
196
207
  // print("Payment error received: \(error)")
197
- sendEvent(withName: "payment_failed", body: error)
208
+ if hasListeners {
209
+ sendEvent(withName: "payment_failed", body: error)
210
+ }
198
211
  }
199
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nimbbl-mobile-react-native-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Nimbbl React Native SDK for payment integration",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",