react-native-twilio-chat
所属分类:iPhone/iOS
开发工具:Java
文件大小:0KB
下载次数:0
上传日期:2017-11-13 17:23:26
上 传 者:
sh-1993
说明: React Native包装器,用于Twilio可编程聊天iOS和Android SDK
(React Native wrapper for the Twilio Programmable Chat iOS and Android SDKs)
文件列表:
.eslintrc (382, 2017-05-12)
CONTRIBUTING.md (1223, 2017-05-12)
Example/ (0, 2017-05-12)
Example/.flowconfig (2784, 2017-05-12)
Example/.watchmanconfig (2, 2017-05-12)
Example/GiftedMessengerContainer.js (7893, 2017-05-12)
Example/Navigation.js (1007, 2017-05-12)
Example/android/ (0, 2017-05-12)
Example/android/app/ (0, 2017-05-12)
Example/android/app/build.gradle (2794, 2017-05-12)
Example/android/app/proguard-rules.pro (2480, 2017-05-12)
Example/android/app/src/ (0, 2017-05-12)
Example/android/app/src/main/ (0, 2017-05-12)
Example/android/app/src/main/AndroidManifest.xml (985, 2017-05-12)
Example/android/app/src/main/java/ (0, 2017-05-12)
Example/android/app/src/main/java/com/ (0, 2017-05-12)
Example/android/app/src/main/java/com/reactnativetwilioipmessagingexample/ (0, 2017-05-12)
Example/android/app/src/main/java/com/reactnativetwilioipmessagingexample/MainActivity.java (414, 2017-05-12)
Example/android/app/src/main/java/com/reactnativetwilioipmessagingexample/MainApplication.java (1132, 2017-05-12)
Example/android/app/src/main/res/ (0, 2017-05-12)
Example/android/app/src/main/res/mipmap-hdpi/ (0, 2017-05-12)
Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (3418, 2017-05-12)
Example/android/app/src/main/res/mipmap-mdpi/ (0, 2017-05-12)
Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (2206, 2017-05-12)
Example/android/app/src/main/res/mipmap-xhdpi/ (0, 2017-05-12)
Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (4842, 2017-05-12)
Example/android/app/src/main/res/mipmap-xxhdpi/ (0, 2017-05-12)
Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (7718, 2017-05-12)
Example/android/app/src/main/res/values/ (0, 2017-05-12)
Example/android/app/src/main/res/values/strings.xml (98, 2017-05-12)
Example/android/app/src/main/res/values/styles.xml (192, 2017-05-12)
Example/android/build.gradle (641, 2017-05-12)
Example/android/gradle.properties (887, 2017-05-12)
Example/android/gradlew.bat (2404, 2017-05-12)
Example/android/settings.gradle (404, 2017-05-12)
Example/capture.png (71726, 2017-05-12)
Example/index.android.js (198, 2017-05-12)
Example/index.ios.js (198, 2017-05-12)
... ...
# React Native Twilio Chat
[![npm version](https://badge.fury.io/js/react-native-twilio-chat.svg)](https://badge.fury.io/js/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](https://github.com/ccm-innovation/react-native-twilio-ip-messaging).*
### [View migration doc from react-native-ip-messaging here](MIGRATION.md)
## 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](./Example/ios/Podfile) for more details.
```ruby
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'React', :subspecs => ['Core', /* any other subspecs you require */], :path => '../node_modules/react-native'
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`:
```java
include ':RCTTwilioChat', ':app'
project(':RCTTwilioChat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-twilio-chat/android')
```
In `android/app/build.gradle`:
```java
...
dependencies {
...
compile project(':RCTTwilioChat')
}
```
Register the module in `MainApplication.java`:
```Java
// import package
import com.bradbumbalough.RCTTwilioChat.RCTTwilioChatPackage;
...
// register package in getPackages()
@Override
protected List getPackages() {
return Arrays.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.
```java
android {
....
dexOptions {
javaMaxHeapSize "2048M"
}
defaultConfig {
...
minSdkVersion 19
multiDexEnabled true
}
```
## Usage
```javascript
/* Initialization */
import {
AccessManager,
Client,
Constants
} from 'react-native-twilio-chat';
// create the access manager
const accessManager = new AccessManager(token);
// specify any handlers for events
accessManager.onTokenWillExpire = () => {
getNewTokenFromServer()
.then(accessManager.updateToken);
}
// create the client
const client = new Client(token);
// specify any global events
client.onError = ({error, userInfo}) => console.log(error);
// initialize the client
client.initialize();
// wait for sync to finish
client.onClientSynchronized = () => {
client.getUserChannels()
.then((channelPaginator) => console.log(channelPaginator.items));
}
/* Individual Channel */
// an instance of Channel is passed down in the app via props
let channel = this.props.channel
// specify channel specific events
channel.onMessageAdded = (message) => console.log(message.author + ": " + message.body);
channel.onTypingStarted = (member) => console.log(member.identity + " started typing...");
channel.onTypingEnded = (member) => console.log(member.identity + " stopped typing...");
channel.onMemberAdded = (member) => console.log(member.identity + " joined " + channel.friendlyName);
// sending a message
{
this.setState({body});
channel.typing();
}}
onSubmitEditing={() => { channel.sendMessage(this.state.body)} }
/>
````
## [Documentation](docs)
## Contributers
Thank you for your help in maintaining this project! Haven't contributed yet? [Check out our Contributing guidelines...](CONTRIBUTING.md).
- [bradbumbalough](https://github.com/bradbumbalough)
- [johndrkurtcom](https://github.com/johndrkurtcom)
- [jck2](https://github.com/jck2)
- [Baisang](https://github.com/Baisang)
- [thathirsch](https://github.com/thathirsch)
- [n8stowell82](https://github.com/n8stowell82)
- [svlaev](https://github.com/svlaev)
- [Maxwell2022](https://github.com/Maxwell2022)
- [bbil](https://github.com/bbil)
- [jhabdas](https://github.com/jhabdas)
- [plonkus](https://github.com/plonkus)
- [mattshen](https://github.com/mattshen)
- [Kabangi](https://github.com/Kabangi)
- [benoist](https://github.com/benoist)
## TODO
* [x] Copy code from `programable-chat` branch on old package
* [x] Copy issues and PRs over
* [x] Update docs (wiki?)
* [x] Migration guide
* [x] Publish to npm
* [x] Update `twilio-ip-messaging` to reference `twilio-chat`
* [ ] 1.0 release
* [ ] Testing
## License
This project is licensed under the [MIT License](LICENSE).
近期下载者:
相关文件:
收藏者: