@developer_tribe/react-native-comnyx
v0.16.1
Published
React Native chat component with integrated support panel, enabling real-time customer communication and efficient agent workflow management.
Readme
Comnyx Push Notification Service Documentation
Installation
npm install @developer_tribe/react-native-comnyx
# or
yarn add @developer_tribe/react-native-comnyxRequired Peer Dependencies
For persistent storage support, you need to install react-native-mmkv:
npm install react-native-mmkv
# or
yarn add react-native-mmkvThen, rebuild your app:
# For iOS
cd ios && pod install && cd ..
npx react-native run-ios
# For Android
npx react-native run-androidNote: If you don't install react-native-mmkv, the SDK will use in-memory storage as a fallback. This means your data will not persist between app restarts.
iOS Podfile (required for React Native 0.85+)
React Native 0.85 ships React-Core as a prebuilt XCFramework whose umbrella header is not compatible with Xcode 26's strict Clang explicit modules. Without the patch below, pod install succeeds but xcodebuild fails while compiling the React-Core umbrella.
Comnyx ships a helper that applies the required build setting to every pod target. Wire it into your ios/Podfile:
require_relative '../node_modules/@developer_tribe/react-native-comnyx/ios/comnyx_post_install'
# ...
target 'YourApp' do
config = use_native_modules!
use_react_native!(:path => config[:reactNativePath], :app_path => "#{Pod::Config.instance.installation_root}/..")
post_install do |installer|
comnyx_post_install(installer)
react_native_post_install(installer, config[:reactNativePath], :mac_catalyst_enabled => false)
end
endThen reinstall pods:
cd ios && pod install && cd ..The helper is a no-op on React Native < 0.85, so it is safe to add before upgrading.
Basic Setup (Required)
1. Initialization and Login
// Initialize Comnyx with your token
Comnyx.init({
projectId: 'YOUR_TOKEN',
});
// Login with user's external ID
await Comnyx.login({
externalId: 'YOUR_USER_ID',
});
// Logout when needed
await Comnyx.logout();Support Implementation (Optional)
1. Data Collection
// Collect relevant user data
Comnyx.collectData('userType', 'your_user_type');
Comnyx.collectData('deviceType', 'iOS');
Comnyx.collectData('userLanguage', 'en');2. Support Component
const SupportScreen = () => {
return (
<ComnyxSupport
fake={false}
language="en"
theme="dark"
onBack={() => navigation.goBack()}
themes={{}}
/>
);
};3. Media Attachments in Support (iOS Info.plist)
The support UI lets users attach images and videos. On Android the system
Photo Picker (Android 13+) or the document picker (older) handles this
permission-free. On iOS the SDK uses PHPicker on iOS 14+ (no permission
needed) and falls back to UIImagePickerController on iOS 13.
If you ship iOS 13 support, add the following to your host app's
Info.plist so the fallback works without crashing:
<key>NSPhotoLibraryUsageDescription</key>
<string>Needed to attach photos and videos to support conversations.</string>If your deployment target is iOS 14+, this key is not strictly required but
App Store reviewers often expect it whenever PHPickerViewController is
linked.
Push Notifications Setup (Optional)
1. Account Prerequisites
Apple Developer Account Setup:
- Go to Apple Developer Account → Keys
- Generate and download the key file (
.p8) - Upload the
.p8file to Comnyx panel
Firebase Setup:
- Implement Firebase in your project
- Obtain Firebase secret key
- Configure Google Services
2. iOS Configuration
Add to your Info.plist:
<key>NSUserNotificationsUsageDescription</key>
<string>We need to send you notifications for important updates.</string>
<key>NSUserNotificationsEnabled</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>3. Xcode Settings
Enable Remote Notifications:
- Open Xcode → Target's capabilities
- Enable "Background Modes"
- Check "Remote Notifications"
Add Push Notifications:
- Select target → "Signing & Capabilities"
- Add "Push Notifications" capability
4. Platform-Specific Requirements
Android: Handle New Intents
In your MainActivity.kt, add the following method to handle notification intents:
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
ComnyxModule.handleNewIntent(intent)
}iOS: Register Device Tokens
In your AppDelegate.swift, add these methods to handle push notification registration:
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Comnyx.registerDeviceToken(deviceToken)
}
override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
Comnyx.registerDeviceTokenFailed(error)
}5. Notifications Code Setup
// Initialize notifications
await ComnyxNotifications.optIn();
await ComnyxNotifications.initialize();5. Notification Event Listeners
useEffect(() => {
// Set up event listeners
const subscriptions = [
// Listen for token initialization
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
console.info('Token received:', data.token);
}),
// Listen for token initialization failures
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
console.info('Token initialization failed:', data);
}),
// Listen for incoming notifications
ComnyxNotifications.addEventListener('NOTIFICATION_RECEIVED', (data) => {
console.info('Notification received:', data);
}),
// Listen for notification clicks
ComnyxNotifications.addEventListener('NOTIFICATION_CLICKED', (data) => {
console.info('Notification clicked:', data);
}),
];
// Cleanup subscriptions when component unmounts
return () => {
subscriptions.forEach((subscription) => subscription.remove());
};
}, []);Complete Implementation Example
import { Comnyx, ComnyxNotifications } from 'comnyx-rn';
import { useEffect } from 'react';
// Basic Setup (Required)
Comnyx.init({
token: 'YOUR_TOKEN',
});
await Comnyx.login({ externalId: 'USER_ID' });
// Support Setup (Optional)
Comnyx.collectData('userType', 'premium');
Comnyx.collectData('deviceType', 'iOS');
Comnyx.collectData('userLanguage', 'en');
// Notifications Setup (Optional)
await ComnyxNotifications.optIn();
await ComnyxNotifications.initialize();
// Notification Event Listeners
useEffect(() => {
const subscriptions = [
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
console.info('Token received:', data.token);
}),
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
console.info('Token initialization failed:', data);
}),
ComnyxNotifications.addEventListener('NOTIFICATION_RECEIVED', (data) => {
console.info('Notification received:', data);
}),
ComnyxNotifications.addEventListener('NOTIFICATION_CLICKED', (data) => {
console.info('Notification clicked:', data);
}),
];
return () => {
subscriptions.forEach((subscription) => subscription.remove());
};
}, []);
// Support Screen Component
const SupportScreen = () => {
return (
<ComnyxSupport
fake={false}
language="en"
theme="dark"
onBack={() => navigation.goBack()}
themes={{}}
/>
);
};
// Logout when user signs out
const handleLogout = async () => {
await Comnyx.logout();
};Important Notes
- Replace 'YOUR_TOKEN' with your actual Comnyx token
- Replace 'USER_ID' with your actual user identification
- Customize collected data based on your needs
- Ensure all prerequisites are properly configured
Troubleshooting
- Verify Xcode capabilities are enabled
- Confirm
.p8file is uploaded to Comnyx panel - Check Firebase configuration
- Verify bundle identifier matches Apple Developer account
