ConnectyCube expo react native support for RNChat

108 views Asked by At

Is there a chance to get an RNChat example which runs on latest expo react native for supporting the great expo plugins like expo av player or expo haptics?

Edit: Build fails

=== BUILD TARGET React-Codegen OF PROJECT Pods WITH CONFIGURATION Debug ===

Check dependencies

** BUILD FAILED **

The following build commands failed: CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler CompileSwift normal x86_64 (2 failures)

I get tons of errors using the expo and expo-modules-core like:

expo-modules-core/ Class Components Factories swift:71:52: error: unknown attribute '_implicitSelfCapture'

OR

expo-modules-core/ios/Swift/DynamicTypes/DynamicEnumType.swift:7:22: error: expected declaration let innerType: any Enumerable.Type

1

There are 1 answers

0
ccvlad On

Unfortunately, we don't have the chat app example for Expo. Errors you've provided aren't related to ConnectyCube's services.

You can make chat app using our ConnectyCube SDK. The SDK supports Expo except WebRTC (video/audio calls).

See docs how to use ConnectyCube's API and chat for React Native here

Try simple code how to use ConnectyCube SDK with Expo:

  1. npx create-expo-app ExpoConnectyCube
  2. cd ExpoConnectyCube
  3. yarn add react-native-connectycube
  4. yarn ios
    import { StatusBar } from "expo-status-bar";
    import { useEffect, useState } from "react";
    import { StyleSheet, Text, View } from "react-native";
    import ConnectyCube from "react-native-connectycube";
    const creds = {
      appId: 385,
      authKey: "DFBMs5-dKBBCXcd",
      authSecret: "SkCW-ThdnmRg9Za",
    };
    
    const conf = {
      debug: { mode: 1 },
    };
    
    const user = {
      id: 72780,
      login: "videouser1",
      password: "videouser1",
    };
    export default function App() {
      const [session, setSession] = useState("empty");
      const [chat, setChat] = useState(false);
      const [message, setMessage] = useState("");
    
      const initConnectyCube = () => {
        ConnectyCube.init(creds, conf);
      };
    
      const createAuthSession = () => {
        ConnectyCube.createSession({ login: user.login, password: user.password })
          .then((result) => {
            setSession(result);
          })
          .catch((sessionError) => setChat(sessionError));
      };
    
      const chatConnect = () => {
        ConnectyCube.chat.onMessageListener = (user, message) => {
          setMessage({ user, message });
        };
    
        ConnectyCube.chat
          .connect({ userId: user.id, password: user.password })
          .then(() => {
            setChat(true);
            ConnectyCube.chat.send(user.id, { body: "Hello", type: "chat" });
          })
          .catch((chatError) => setChat(chatError));
      };
    
      useEffect(() => {
        initConnectyCube();
        createAuthSession();
        chatConnect();
      }, []);
    
      return (
        <View style={styles.container}>
          <Text>{`Session: ${JSON.stringify(session)} \n`}</Text>
          <Text>{`Chat connected: ${chat} \n`}</Text>
          <Text>{`onMessage: ${JSON.stringify(message)} \n`}</Text>
          <StatusBar style="auto" />
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: "#fff",
        justifyContent: "center",
      },
    });