react-native-tone-framework v1.0.9
React Native Tone Framework Documentation
Table of Contents
- Introduction
- Installation
- Prerequisites
- Platform Setup
- Basic Usage
- API Reference
- Event Handling
- Permissions
- Advanced Features
- Troubleshooting
License
Introduction
The React Native Tone Framework is a specialized module that enables TONE-enabled content sharing and streaming capabilities in React Native applications. It allows businesses to exchange marketing and mobile engagement concepts through audio frequency detection.
Key Features:
- Audio frequency detection
- Content sharing
- Marketing engagement
- Cross-platform support (iOS & Android)
- Offline mode support
- Location-based services
- Installation
Install via npm:
npm install react-native-tone-framework
Or using yarn:
yarn add react-native-tone-framework
- Prerequisites
- Client key from Tone Framework official site
- Android API level 22 or above
- iOS version 12 or above
- React Native version 0.59 or above
- Platform Setup
iOS Setup: 1. Add required permissions to Info.plist:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We use the location to provide accurate and relative information for users</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>We use the location to provide accurate and relative information for users</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We use the location to provide accurate and relative information for users</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires microphone access to enable voice commands.</string>
- Enable Background Modes capabilities for:
- Microphone usage
- Location updates
Android Setup: 1. Add permissions to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
- Add dependency to build.gradle:
implementation 'com.google.code.gson:gson:2.10.1'
- Basic Usage
Import required functions:
import {
initFramework,
setClientID,
requestPermission,
start,
stop,
onToneReceived,
onToneTag
} from 'react-native-tone-framework';
Basic implementation:
useEffect(() => {
// Initialize framework
initFramework();
// Request necessary permissions
requestPermission();
// Set client ID
setClientID('your-client-id');
// Start listening
start();
// Setup listeners
const toneReceivedListener = onToneReceived((toneData) => {
console.log('Tone received:', toneData);
});
const toneTagListener = onToneTag(({ toneTag, isBadCode }) => {
console.log('Tone tag:', toneTag, 'Is bad code:', isBadCode);
});
return () => {
// Cleanup
stop();
toneReceivedListener.remove();
toneTagListener.remove();
};
}, []);
- API Reference
Core Functions:
- initFramework(): Initialize the Tone Framework
- setClientID(clientID: string): Set the client identification
- requestPermission(): Request necessary platform permissions
- start(): Start tone detection
- stop(): Stop tone detection
- restart(): Restart the framework
- removeListeners(): Remove all event listeners
Offline Mode Functions:
- enableOfflineMode(): Enable offline functionality
- disableOfflineMode(): Disable offline functionality
- downloadOfflineData(): Download data for offline use
- deleteOfflineData(): Clear offline data
Platform Specific Functions:
- startReceiver(): Start receiver (Android only)
- stopReceiver(): Stop receiver (Android only)
- enableAppleExclusivePermission(): Enable iOS specific permissions
- disableAppleExclusivePermission(): Disable iOS specific permissions
- showDefaultToneTagSheet(): Show default tone tag sheet (iOS only)
- Event Handling
The framework provides two main event listeners:
onToneReceived:
const listener = onToneReceived((toneData) => {
// Handle received tone data
});
onToneTag:
const listener = onToneTag(({ toneTag, isBadCode }) => {
// Handle tone tag data
});
- Permissions
The framework requires several permissions:
- Location (Fine location for Android)
- Microphone access
- Notifications (Android)
- Background mode capabilities (iOS)
Use requestPermission() to handle permission requests:
await requestPermission();
- Advanced Features
Offline Mode:
// Enable offline mode
enableOfflineMode();
// Download data for offline use
downloadOfflineData();
// Disable offline mode
disableOfflineMode();
// Clear offline data
deleteOfflineData();
Platform Specific Features:
iOS:
// Enable Apple exclusive permissions
enableAppleExclusivePermission();
// Show default tone tag sheet
showDefaultToneTagSheet();
Android:
// Manage receiver
startReceiver();
stopReceiver();
- Troubleshooting
Common Issues:
- Framework not initialized:
- Ensure initFramework() is called before other functions
- Verify client ID is set correctly
- Permissions not granted:
- Call requestPermission() before starting the framework
- Check platform-specific permission settings
- Events not receiving:
- Verify listeners are properly set up
- Check if framework is started
- Ensure cleanup is handled properly
- Platform specific issues: iOS:
- Verify background modes are enabled
- Check Info.plist permissions
Android:
- Verify manifest permissions
- Check gradle dependencies
- License
Proprietary License - TheToneknows Company
This framework is proprietary software owned by TheToneknows Company. Usage of this framework requires a valid license that must be purchased from TheToneknows Company.
License Requirements:
- Commercial license must be purchased from TheToneknows Company
- One license per application/implementation
- License is non-transferable
- Unauthorized use, reproduction, or distribution is prohibited
To obtain a license, please contact: TheToneknows Company Website: https://thetoneknows.com Email: licensing@thetoneknows.com
For more information and support, visit: https://github.com/Anilkumar18/react-native-tone-framework