UNPKG

react-native-tone-framework

Version:

TONE Telegenics is a TONE-Enabled content sharing and streaming platform for businesses to exchange marketing and mobile engagement concepts

267 lines (221 loc) 6.69 kB
React Native Tone Framework Documentation ======================================= Table of Contents ---------------- 1. Introduction 2. Installation 3. Prerequisites 4. Platform Setup 5. Basic Usage 6. API Reference 7. Event Handling 8. Permissions 9. Advanced Features 10. Troubleshooting 11. License 1. 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 2. Installation -------------- Install via npm: ``` npm install react-native-tone-framework ``` Or using yarn: ``` yarn add react-native-tone-framework ``` 3. 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 4. Platform Setup ---------------- iOS Setup: 1. Add required permissions to Info.plist: ```xml <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> ``` 2. Enable Background Modes capabilities for: - Microphone usage - Location updates Android Setup: 1. Add permissions to AndroidManifest.xml: ```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" /> ``` 2. Add dependency to build.gradle: ```gradle implementation 'com.google.code.gson:gson:2.10.1' ``` 5. Basic Usage ------------- Import required functions: ```javascript import { initFramework, setClientID, requestPermission, start, stop, onToneReceived, onToneTag } from 'react-native-tone-framework'; ``` Basic implementation: ```javascript 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(); }; }, []); ``` 6. 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) 7. Event Handling ---------------- The framework provides two main event listeners: onToneReceived: ```javascript const listener = onToneReceived((toneData) => { // Handle received tone data }); ``` onToneTag: ```javascript const listener = onToneTag(({ toneTag, isBadCode }) => { // Handle tone tag data }); ``` 8. 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: ```javascript await requestPermission(); ``` 9. Advanced Features ------------------- Offline Mode: ```javascript // Enable offline mode enableOfflineMode(); // Download data for offline use downloadOfflineData(); // Disable offline mode disableOfflineMode(); // Clear offline data deleteOfflineData(); ``` Platform Specific Features: iOS: ```javascript // Enable Apple exclusive permissions enableAppleExclusivePermission(); // Show default tone tag sheet showDefaultToneTagSheet(); ``` Android: ```javascript // Manage receiver startReceiver(); stopReceiver(); ``` 10. Troubleshooting ------------------ Common Issues: 1. Framework not initialized: - Ensure initFramework() is called before other functions - Verify client ID is set correctly 2. Permissions not granted: - Call requestPermission() before starting the framework - Check platform-specific permission settings 3. Events not receiving: - Verify listeners are properly set up - Check if framework is started - Ensure cleanup is handled properly 4. Platform specific issues: iOS: - Verify background modes are enabled - Check Info.plist permissions Android: - Verify manifest permissions - Check gradle dependencies 11. 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