Skip to content

Releases: pushpender-singh-ap/react-native-otp-verify

v1.2.0 - iOS Support & Enhanced CI Pipeline

Choose a tag to compare

@pushpender-singh-ap pushpender-singh-ap released this 15 Oct 21:50
93c149e

🎉 v1.2.0 - iOS Support & Enhanced CI

Highlights:

  • 🍎 Native iOS support with graceful error handling
  • 🚀 iOS CI build pipeline
  • 🔧 Simplified configuration
  • 📚 Improved documentation

No More iOS Build Errors!

✅ Proper CocoaPods integration
✅ Works out of the box
✅ Clear error messages
✅ Zero configuration needed

📦 Installation

npm install @pushpendersingh/react-native-otp-verify@1.2.0

or

yarn add @pushpendersingh/react-native-otp-verify@1.2.0

Migration: None required - fully backward compatible!

Full Details: CHANGELOG.md

What's Changed

Full Changelog: 1.1.0...1.2.0

v1.1.0 - Modern EventEmitter & Thread-Safe Operations

Choose a tag to compare

@pushpender-singh-ap pushpender-singh-ap released this 15 Oct 20:09
27c4018

🎉 What's New in v1.1.0

This release brings significant improvements to @pushpendersingh/react-native-otp-verify, focusing on modernizing event handling, adding thread-safety, and improving overall reliability and debuggability.

✨ Key Features

1. Modern Event Handling Pattern

  • Migrated to TurboModule's native EventEmitter - Moved from legacy NativeEventEmitter to CodegenTypes.EventEmitter<SmsMessage>
  • Better Performance - Reduced overhead in event emission path
  • Type-Safe Events - Full TypeScript support with proper type definitions
  • Improved Reliability - Better integration with React Native's new architecture

2. Thread-Safe Receiver Management

  • ReentrantLock - Thread-safe receiver registration/unregistration
  • AtomicBoolean - Concurrent-safe state tracking
  • @volatile Annotations - Cross-thread visibility guarantees
  • Race Condition Prevention - Eliminates potential concurrency issues

3. Enhanced Logging & Debugging

  • Comprehensive Debug Logs - Track SMS receiver operations
  • Warning Logs - Identify edge cases and potential issues
  • Error Logs with Stack Traces - Easier troubleshooting and debugging
  • Better Developer Experience - More visibility into what's happening

4. Code Quality Improvements

  • KDoc Comments - Comprehensive inline documentation
  • Better Error Handling - Graceful handling of edge cases
  • Cleaner Dependencies - Removed unnecessary dependencies
  • Improved Code Organization - More maintainable codebase

🐛 Bug Fixes

  • Fixed potential race conditions in receiver registration/unregistration
  • Improved cleanup in error scenarios
  • Better handling of already-registered receivers
  • Proper thread synchronization for concurrent operations

📈 Performance Improvements

  • Reduced event emission overhead
  • More efficient thread-safe operations
  • Better memory management with proper cleanup
  • Reduced risk of memory leaks from unregistered receivers

🔄 Breaking Changes

None! This is a fully backward-compatible update. All existing code continues to work without any modifications required.

📦 Installation

npm install @pushpendersingh/react-native-otp-verify@1.1.0

or

yarn add @pushpendersingh/react-native-otp-verify@1.1.0

🚀 Migration Guide

No migration needed! Your existing code will work as-is:

import { addSmsListener, startSmsRetriever } from '@pushpendersingh/react-native-otp-verify';

// This code works exactly the same, but now with better performance
const subscription = addSmsListener((message) => {
  console.log('SMS received:', message);
});

await startSmsRetriever();

📋 What's Changed

Native Module (Kotlin)

  • Enhanced ReactNativeOtpVerifyModule.kt with thread-safe operations
  • Added comprehensive logging throughout
  • Migrated to modern event emission pattern
  • Improved error handling and cleanup

TypeScript/JavaScript

  • Updated NativeReactNativeOtpVerify.ts with new EventEmitter spec
  • Simplified index.tsx by removing manual event emitter
  • Added proper type exports for SmsMessage

Documentation

  • Updated README.md with new features
  • Added comprehensive CHANGELOG.md
  • Improved inline code documentation

🔗 Full Changelog

See CHANGELOG.md for detailed technical changes.

📚 Documentation

🙏 Credits

Special thanks to the React Native community and everyone using this library!

📄 License

MIT © Pushpender Singh


⚡ Quick Links


What's Changed

New Contributors

Full Changelog: 1.0.0...1.1.0

v1.0.0 - Zero-Permission SMS OTP Verification for Android

Choose a tag to compare

@pushpender-singh-ap pushpender-singh-ap released this 01 Oct 00:40
2575e4d

🎉 Initial Release - SMS OTP Verification for React Native Android

Automatic SMS OTP verification using Google's SMS Retriever API and SMS User Consent API with zero permissions required.


✨ Key Features

  • 🔐 Two verification methods: Automatic (SMS Retriever) and User-Consent based
  • 🚫 Zero permissions: No READ_SMS or RECEIVE_SMS needed
  • ✅ Google Play approved: Uses official Google Play Services APIs
  • 🎯 Easy integration: Simple JavaScript API with full TypeScript support
  • 📱 Android only: iOS throws descriptive error
  • 🔄 Event-driven: Real-time SMS listening with callbacks
  • 🛠️ Modern architecture: Built with React Native TurboModules

📦 Installation

npm install @pushpendersingh/react-native-otp-verify

or

yarn add @pushpendersingh/react-native-otp-verify

🚀 Quick Start

import { 
  startSmsRetriever, 
  addSmsListener, 
  getAppSignature, 
  extractOtp 
} from '@pushpendersingh/react-native-otp-verify';

// Get app signature for your backend
const signature = await getAppSignature();

// Start listening for SMS
await startSmsRetriever();

// Listen for incoming OTP
const removeListener = addSmsListener((message) => {
  if (message.status === 'success') {
    const otp = extractOtp(message.message);
    console.log('OTP:', otp);
  }
});

🎯 What's Included

Native Implementation (Kotlin)

  • ✅ SMS Retriever API integration
  • ✅ SMS User Consent API integration
  • ✅ App signature hash generator (11-character Base64)
  • ✅ BroadcastReceiver for SMS events
  • ✅ Activity result handling for consent dialogs
  • ✅ Android API 19+ support

JavaScript API

  • ✅ startSmsRetriever() - Start automatic SMS listening
  • ✅ getAppSignature() - Get app hash for SMS formatting
  • ✅ requestPhoneNumber() - Start consent-based verification
  • ✅ addSmsListener() - Listen for SMS events
  • ✅ removeSmsListener() - Stop listening
  • ✅ extractOtp() - Extract OTP with custom regex support

Documentation

  • ✅ Comprehensive README with all APIs documented
  • ✅ Complete usage examples (Automatic & Consent-based)
  • ✅ Backend integration guide (Node.js example)
  • ✅ SMS format specifications
  • ✅ Troubleshooting guide
  • ✅ Full TypeScript definitions

Example App

  • ✅ Simple demo app with both verification methods
  • ✅ Live testing examples
  • ✅ Clear implementation patterns

📋 API Overview

SMS Retriever (Automatic)

Perfect when you control the SMS format. Captures OTP automatically without user interaction.

// Your backend sends SMS like this:
// <#> Your OTP is: 123456
// 
// FA+9qCX9VSu

await startSmsRetriever();
const removeListener = addSmsListener((message) => {
  const otp = extractOtp(message.message); // "123456"
});

SMS User Consent (Dialog-based)

Works with any SMS format. Shows Google consent dialog - user taps "Allow" to share SMS.

// Works with any SMS format:
// "Your verification code is 123456"

await requestPhoneNumber();
const removeListener = addSmsListener((message) => {
  if (message.status === 'success') {
    const otp = extractOtp(message.message); // "123456"
  }
});

🔧 Requirements

  • React Native >= 0.76+
  • Android API Level >= 24
  • Google Play Services

🆚 Comparison: SMS Retriever vs SMS User Consent

Feature SMS Retriever SMS User Consent
User Action None (Automatic) Tap "Allow"
SMS Format Requires app hash Any format
User Experience Seamless One-tap consent
Best For Your own backend 3rd party SMS
Permission Zero Zero

🛡️ Zero Permissions

Both APIs use Google Play Services and require zero permissions in AndroidManifest.xml.

<!-- AndroidManifest.xml -->
<manifest>
  <!-- No READ_SMS -->
  <!-- No RECEIVE_SMS -->
  <!-- No special permissions needed! -->
</manifest>

🔧 Backend Integration

SMS Format for SMS Retriever

<#> Your OTP is: 123456

YOUR_APP_SIGNATURE

Node.js Example

const signature = 'FA+9qCX9VSu'; // Get from getAppSignature()
const otp = '123456';

const sms = `<#> Your OTP is: ${otp}

${signature}`;

// Send via your SMS provider (Twilio, AWS SNS, etc.)
await sendSMS(phoneNumber, sms);

🐛 Bug Reports & Feature Requests

If you find any issues or have feature requests, please open an issue.


🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.


📄 License

MIT - See LICENSE for details.


🙏 Credits