React Native Twilio Chat
React Native wrapper for the Twilio Programmable Chat iOS and Android SDKs
Note - this project is currently in development for a beta release. If you are looking for the legacy package for the Twilio IP Messaging SDKs, see the original repository here.
View migration doc from react-native-ip-messaging here
Installation
npm install --save react-native-twilio-chat
iOS - CocoaPods
Install the Twilio Chat SDK and this package via CocoaPods. See the full Podfile example for more details.
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'pod 'React', :subspecs => ['Core', /* any other subspecs you pod 'RCTTwilioChat', :path => '../node_modules/react-native-twilio-chat/ios' source 'https://github.com/twilio/cocoapod-specs'pod 'TwilioChatClient', '~> 0.17.1'pod 'TwilioAccessManager', '~> 0.1.3'
Note: the underlying Twilio SDKs require a minimum deployment target of 8.1
. If your project's target is less than this you will get a CocoaPods install error (Unable to satisfy the following requirements...
).
Make sure that you add the $(inherited)
value to Other Linker Flags
and Framework Search Paths
for your target's Build Settings. This is also assuming you have already loaded React via CocoaPods as well.
Android
In android/settings.gradle
:
include ':RCTTwilioChat', ':app'.projectDir = new File(rootProject.projectDir, '../node_modules/react-native-twilio-chat/android')
In android/app/build.gradle
:
...dependencies { ... compile }
Register the module in MainApplication.java
:
// import packageimport com.bradbumbalough.RCTTwilioChat.RCTTwilioChatPackage; ... // register package in getPackages()@Overrideprotected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new RCTTwilioChatPackage(), ... other packages );}
Note: You might have to enable multidex in your build.gradle
file and increase the heap size if you're getting errors while buliding. The minSdkVersion must also be at least 19, per the Twilio SDKs.
android { .... dexOptions { javaMaxHeapSize "2048M" } defaultConfig { ... minSdkVersion 19 multiDexEnabled true }
Usage
/* Initialization */ ; // create the access managerconst accessManager = token; // specify any handlers for eventsaccessManager { ;} // create the clientconst client = token; // specify any global eventsclient console; // initialize the clientclient; // wait for sync to finishclient { client ;} /* Individual Channel */ // an instance of Channel is passed down in the app via propslet channel = thispropschannel // specify channel specific eventschannel console;channel console;channel console;channel console; // sending a message<TextInput onChangeText= { this; channel; } onSubmitEditing= { channel} />
Documentation
Contributers 🍻
Thank you for your help in maintaining this project! Haven't contributed yet? Check out our Contributing guidelines....
- bradbumbalough
- johndrkurtcom
- jck2
- Baisang
- thathirsch
- n8stowell82
- svlaev
- Maxwell2022
- bbil
- jhabdas
- plonkus
- mattshen
- Kabangi
- benoist
TODO 🗒
- Copy code from
programable-chat
branch on old package - Copy issues and PRs over
- Update docs (wiki?)
- Migration guide
- Publish to npm
- Update
twilio-ip-messaging
to referencetwilio-chat
- 1.0 release
- Testing
License
This project is licensed under the MIT License.