Skip to content

mskwierczynski/stream-chat-react-native-2.0.2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Official React Native SDK for Stream Chat

react native chat

The official React Native and Expo components for Stream Chat, a service for building chat applications.

NPM Build Status Component Reference

Quick Links

Contents

๐Ÿ” React Native Compatibility

To use this library you need to ensure you match up with the correct version of React Native you are using.

stream-chat-react-native version Required React Native Version
2.x.x >= 0.60
1.x.x >= 0.59
0.x.x *

๐Ÿ“– React Native Chat Tutorial

The best place to start is the React Native Chat Tutorial. It teaches you how to use this SDK and also shows how to make frequently required changes.

๐Ÿ”ฎ Example Apps

This repo includes 3 example apps. One made with Expo, one Native JavaScript code, and one in TypeScript.

IMAGE ALT TEXT HERE IMAGE ALT TEXT HERE IMAGE ALT TEXT HERE

Expo example

  1. Make sure node version is >= v10.13.0
  2. yarn global add expo-cli
    git clone https://github.com/GetStream/stream-chat-react-native.git
    cd stream-chat-react-native/examples/ExpoMessaging
    yarn && yarn start

Native example

  1. Please make sure you have installed necessary dependencies depending on your development OS and target OS. Follow the guidelines given on official React Native documentation for installing dependencies: https://facebook.github.io/react-native/docs/getting-started#

  2. Make sure node version is >= v10.13.0

  3. Start the simulator

  4. git clone https://github.com/GetStream/stream-chat-react-native.git
    cd stream-chat-react-native
    yarn
    cd stream-chat-react-native/native-package
    yarn
    cd stream-chat-react-native/examples/NativeMessaging
    yarn
    • For iOS

      cd ios && pod install && cd ..
      yarn ios
    • For android

      yarn android

    If you run into following error on android:

    Execution failed for task ':app:validateSigningDebug'.
    > Keystore file '/path_to_project/stream-chat-react-native/examples/NativeMessaging/android/app/debug.keystore' not found for signing config 'debug'.

    You can generate the debug Keystore by running this command in the android/app/ directory: keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 - Reference

Slack clone

Check out our tutorial on how to build a slack clone using react-native and stream-chat-react-native

IMAGE ALT TEXT HERE IMAGE ALT TEXT HERE IMAGE ALT TEXT HERE

๐Ÿ“‹ Docs

The styleguidist docs for stream-chat-react-native document how all the components work.

The React Native components are created using the stream-chat-js library. If you're customizing the components, it's essential to learn how the Chat Server API works. You'll want to review our JS chat API docs.

๐Ÿ’ฌ Keep in mind

  1. Navigation between different components is something we expect consumers to implement. You can check out the example given in this repository

  2. Minor releases may come with some breaking changes, so always check the release notes before upgrading the minor version.

You can see detailed documentation about the components at https://getstream.github.io/stream-chat-react-native

๐Ÿ›  Setup (Setting up a chat app)

Expo package

yarn global add expo-cli
# expo-cli supports following Node.js versions:
# * >=8.9.0 <9.0.0 (Maintenance LTS)
# * >=10.13.0 <11.0.0 (Active LTS)
# * >=12.0.0 (Current Release)
expo init StreamChatExpoExample
cd StreamChatExpoExample

# Add chat expo package
yarn add stream-chat-expo

# If you are using stream-chat-expo <= 0.4.0 and expo <= 34, then you don't need to add @react-native-community/netinfo as dependency, since previously we used NetInfo from react-native package.
expo install @react-native-community/netinfo expo-document-picker expo-image-picker expo-permissions

Please check the example to see usage of the components.

OR you can swap this file for your App.js in the root folder and follow these additional steps:

yarn add @react-native-community/masked-view @react-navigation/native @react-navigation/stack react-native-gesture-handler react-native-get-random-values react-native-reanimated react-native-safe-area-context react-native-screens

and finally

yarn start

Native package

For react native < 0.60

react-native init StreamChatReactNativeExample
cd StreamChatReactNativeExample
yarn add stream-chat-react-native

# https://github.com/react-native-community/react-native-netinfo#react-native-compatibility
# For React native 0.59.x - use @react-native-community/[email protected]
# For React native <= 0.58.x - use @react-native-community/[email protected]
yarn add @react-native-community/[email protected]

# https://github.com/ivpusic/react-native-image-crop-picker#important-note
yarn add [email protected]
yarn add react-native-document-picker

react-native link @react-native-community/netinfo

# if you are planning to use image picker or file picker or both
react-native link react-native-image-crop-picker
react-native link react-native-document-picker

Please check the example to see the usage of these components.

OR you can swap this file for your App.js in the root folder and follow this guide for your installed version https://reactnavigation.org/docs/getting-started#installing-dependencies-into-a-bare-react-native-project

If you are planning to use the image crop picker, there are some additional steps to be done. You can find them here - https://github.com/ivpusic/react-native-image-crop-picker/blob/v0.25.0/README.md#install

If you are planning to use file/document picker, you need to enable iCloud capability in your app - https://github.com/Elyx0/react-native-document-picker#reminder

and finally

react-native run-ios

For react native >= 0.60

react-native init StreamChatReactNativeExample
cd StreamChatReactNativeExample
yarn add stream-chat-react-native
yarn add @react-native-community/netinfo react-native-image-crop-picker react-native-document-picker react-native-get-random-values
cd ios && pod install && cd ..

You also need to import react-native-get-random-values in your index.js in root directory, before importing your main app component.

Just to be sure, please verify you are using the appropriate version of the following packages as per your react-native version.

Please check the example to see the usage of components.

OR you can swap this file for your App.js in the root folder by following these additional steps:

yarn add @react-native-community/masked-view @react-navigation/native @react-navigation/stack react-native-gesture-handler  react-native-reanimated react-native-safe-area-context react-native-screens
cd ios && pod install && cd ..

If you are planning to use an image crop picker, there are some additional steps to be done. You can find them here - https://github.com/ivpusic/react-native-image-crop-picker#install

If you are planning to use file/document picker, you need to enable iCloud capability in your app - https://github.com/Elyx0/react-native-document-picker#reminder

and finally

iOS:

yarn ios

Note for Android:

If you are using AndroidX app:

AndroidX is a major step forward in the Android ecosystem, and the old support library artifacts are being deprecated. For 0.60, React Native has been migrated over to AndroidX. This is a breaking change, and your native code and dependencies will need to be migrated as well.

(Reference: https://facebook.github.io/react-native/blog/2019/07/03/version-60#androidx-support)

In current context, dependencies such as react-native-document-picker and (if you are using react-navigation) react-native-gesture-handler, react-native-reanimated don't have AndroidX support. But an awesome tool named jetifier is quite useful to patch these dependencies with AndroidX support.

NOTE If you are planning to use file picker functionality, make sure you enable iCloud capability in your app

Enable iCloud capability

๐Ÿ’ช TypeScript Support

As of version 2.0.0 stream-chat-react-native has been converted to TypeScript. Please read Typescript guide for details.

โœˆ๏ธ Internationalisation

Please read Internationalization doc for details.

๐Ÿš€ Upgrading

Please refer to Upgrade Helper

โš ๏ธ Common issues

While running native example, you may (not necessarily) run into the following issues

  1. When you execute yarn ios for the first time, it starts a metro bundler in parallel. It can result in some errors since the build process isn't complete yet. Try the following to fix this:

    1. Close/stop the metro bundler process.
    2. Let the build process finish. It can usually take around 2-3 minutes for the first time.
    3. Start the metro bundler manually by executing yarn start inside stream-chat-react-native/examples/NativeMessaging directory.
  2. When you execute yarn android, you may (not necessarily) run into following error:

    info Starting JS server...
    info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
    Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':@react-native-community_netinfo'.
    > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 13s
    error Could not install the app on the device, read the error above for details.
    Make sure you have an Android emulator running or a device connected and have
    set up your Android development environment:
    https://facebook.github.io/react-native/docs/getting-started.html
    error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
    

    To resolve this, do the following.

    1. Create a file named local.properties inside stream-chat-react-native/examples/NativeMessaging/android directory

    2. Put the this line in that file. Make sure sdk path is correctly mentioned as per your system:

      sdk.dir=/Users/{user_name}/Library/Android/sdk/
      
    3. Rerun yarn android in stream-chat-react-native/examples/NativeMessaging directory

๐Ÿ‘ Contributing

We welcome code changes that improve this library or fix a problem, and please make sure to follow all best practices and test all the changes. Please check our dev setup docs to get you started. We are pleased to merge your code into the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published