-
Notifications
You must be signed in to change notification settings - Fork 2
FCE-2534: Create mobile fishjam chat example app #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ba21247
Add missing dependencies to livestreaming
anna1901 c327bd4
Create mobile-fishjam-chat example app
anna1901 fcc0ec3
Make screens look like in mobile-sdk
anna1901 318e97e
wip crashing
anna1901 69d3eba
Add permissions
anna1901 68276cd
Livestreams UI improvements
anna1901 e4fe931
Prepare for fishjam room
anna1901 da752c3
Working version of room view
anna1901 8af61f7
Fix layout in fishjam room
anna1901 061c19e
Add logic for choosing between staging and production
anna1901 4bfedbe
Update screen-sharing.tsx
anna1901 f0abc11
Save user info to async storage
anna1901 abaca51
Fix keyboard dismissal
anna1901 b141dad
Merge branch 'mobile-sdk-2-0' into FCE-2534/fishjam-chat
anna1901 c224b06
Add try catches
anna1901 fa68f2b
Fix readme
anna1901 30ade92
Add proper assets
anna1901 8deb373
Apply suggestions from copilot
anna1901 515d3bd
Remove unnecessary varibales
anna1901 8baf1a0
Remove old fishjam-chat example
anna1901 5059130
Rename to fishjam-chat
anna1901 8492cbd
Fix connecting to staging
anna1901 c6f23e4
Remove vscode settings
anna1901 450930a
Add screen sharing (not working)
anna1901 9d62961
Show loading while connecting streamer
anna1901 f09951c
Load data when room tab is in focus
anna1901 05647bd
Merge branch 'mobile-sdk-2-0' into FCE-2534/fishjam-chat
anna1901 d26fded
Update yarn.lock
anna1901 d7551e8
Merge branch 'mobile-sdk-2-0' into FCE-2534/fishjam-chat
anna1901 2cfe286
Update yarn.lock
anna1901 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| EXPO_PUBLIC_FISHJAM_ID= | ||
| EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # dependencies | ||
| node_modules/ | ||
|
|
||
| # Expo | ||
| .expo/ | ||
| dist/ | ||
| web-build/ | ||
| expo-env.d.ts | ||
|
|
||
| # Native | ||
| .kotlin/ | ||
| *.orig.* | ||
| *.jks | ||
| *.p8 | ||
| *.p12 | ||
| *.key | ||
| *.mobileprovision | ||
|
|
||
| # Metro | ||
| .metro-health-check* | ||
|
|
||
| # debug | ||
| npm-debug.* | ||
| yarn-debug.* | ||
| yarn-error.* | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # local env files | ||
| .env*.local | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
|
|
||
| app-example | ||
|
|
||
| # generated native folders | ||
| /ios | ||
| /android |
1 change: 1 addition & 0 deletions
1
examples/mobile-client/mobile-fishjam-chat/.vscode/extensions.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| { "recommendations": ["expo.vscode-expo-tools"] } | ||
7 changes: 7 additions & 0 deletions
7
examples/mobile-client/mobile-fishjam-chat/.vscode/settings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll": "explicit", | ||
| "source.organizeImports": "explicit", | ||
| "source.sortMembers": "explicit" | ||
anna1901 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # React Native Fishjam example | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Create a `.env` file in the `examples/mobile-client/mobile-fishjam-chat` directory (optional), or copy the `.env.example` file. The following environment variables are required: | ||
|
|
||
| - `EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL` - Sandbox URL for VideoRoom staging environment | ||
| - `EXPO_PUBLIC_FISHJAM_ID` - Fishjam ID for production environment | ||
|
|
||
| ## Example Overview | ||
|
|
||
| The app has 2 tabs showing different ways to connect to Fishjam video calls: | ||
|
|
||
| **VideoRoom** - Connect to VideoRoom (Fishjam's demo service, something like Google Meet) by entering a room name and username. The app automatically creates the room and generates tokens for you. | ||
|
|
||
| **Livestream** - Join existing livestreams or create your own livestream. | ||
|
|
||
| ## Project setup | ||
|
|
||
| 1. Clone the repository: | ||
|
|
||
| ``` | ||
| git clone https://github.com/fishjam-cloud/web-client-sdk.git | ||
| cd web-client-sdk | ||
| ``` | ||
|
|
||
| 2. Install dependencies and build project: | ||
|
|
||
| ```cmd | ||
| yarn | ||
| yarn build | ||
| ``` | ||
|
|
||
| 3. Prebuild native files in example directory: | ||
|
|
||
| ```cmd | ||
| cd examples/mobile-client/mobile-fishjam-chat | ||
| npx expo prebuild --clean | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > Be sure to run `npx expo prebuild` and not `yarn prebuild` as there's an issue with path generation for the `ios/.xcode.env.local` file | ||
|
|
||
| 4. Build app: | ||
|
|
||
| ``` | ||
| yarn ios | ||
| yarn android | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| 1. Whenever you make changes in the `packages` directory, make sure to build the app in the root directory (not in `examples/mobile-client/mobile-fishjam-chat`). This ensures that all related workspaces are also built: | ||
| ```cmd | ||
| yarn build | ||
| ``` | ||
| 2. Linter (run in the root directory): | ||
| ```cmd | ||
| yarn lint | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| "expo": { | ||
| "name": "mobile-fishjam-chat", | ||
| "slug": "mobile-fishjam-chat", | ||
| "version": "1.0.0", | ||
| "orientation": "portrait", | ||
| "icon": "./assets/images/icon.png", | ||
| "scheme": "mobilefishjamchat", | ||
| "userInterfaceStyle": "automatic", | ||
| "newArchEnabled": true, | ||
| "ios": { | ||
| "supportsTablet": true, | ||
| "bundleIdentifier": "com.anonymous.mobilefishjamchat", | ||
| "infoPlist": { | ||
| "NSCameraUsageDescription": "Allow $(PRODUCT_NAME) to access your camera.", | ||
| "NSMicrophoneUsageDescription": "Allow $(PRODUCT_NAME) to access your microphone." | ||
| }, | ||
| "appleTeamId": "J5FM626PE2" | ||
| }, | ||
| "android": { | ||
| "adaptiveIcon": { | ||
| "foregroundImage": "./assets/images/adaptive-icon.png", | ||
| "monochromeImage": "./assets/images/adaptive-icon.png", | ||
| "backgroundColor": "#ffffff" | ||
| }, | ||
| "edgeToEdgeEnabled": true, | ||
| "predictiveBackGestureEnabled": false, | ||
| "permissions": [ | ||
| "android.permission.CAMERA", | ||
| "android.permission.RECORD_AUDIO", | ||
| "android.permission.MODIFY_AUDIO_SETTINGS", | ||
| "android.permission.ACCESS_NETWORK_STATE", | ||
| "android.permission.ACCESS_WIFI_STATE" | ||
| ], | ||
| "package": "com.anonymous.mobilefishjamchat" | ||
| }, | ||
| "web": { | ||
| "output": "static", | ||
| "favicon": "./assets/images/favicon.png" | ||
| }, | ||
| "plugins": [ | ||
| "expo-router", | ||
| [ | ||
| "expo-splash-screen", | ||
| { | ||
| "image": "./assets/images/splash.png", | ||
| "resizeMode": "contain", | ||
| "backgroundColor": "#ffffff", | ||
| "dark": { | ||
| "backgroundColor": "#000000" | ||
| } | ||
| } | ||
| ] | ||
| ], | ||
| "experiments": { | ||
| "typedRoutes": true, | ||
| "reactCompiler": true | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
examples/mobile-client/mobile-fishjam-chat/app/(tabs)/_layout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { Tabs } from "expo-router"; | ||
| import { Ionicons } from "@expo/vector-icons"; | ||
| import { BrandColors } from "../../utils/Colors"; | ||
|
|
||
| export default function TabLayout() { | ||
| return ( | ||
| <Tabs | ||
| screenOptions={{ | ||
| tabBarActiveTintColor: BrandColors.darkBlue100, | ||
| tabBarInactiveTintColor: "#8E8E93", | ||
| headerShown: false, | ||
| }} | ||
| > | ||
| <Tabs.Screen | ||
| name="room" | ||
| options={{ | ||
| title: "Room", | ||
| tabBarIcon: ({ color, size }) => ( | ||
| <Ionicons name="videocam" size={size} color={color} /> | ||
| ), | ||
| }} | ||
| /> | ||
| <Tabs.Screen | ||
| name="livestream" | ||
| options={{ | ||
| title: "Livestream", | ||
| tabBarIcon: ({ color, size }) => ( | ||
| <Ionicons name="radio" size={size} color={color} /> | ||
| ), | ||
| }} | ||
| /> | ||
| </Tabs> | ||
| ); | ||
| } |
143 changes: 143 additions & 0 deletions
143
examples/mobile-client/mobile-fishjam-chat/app/(tabs)/livestream.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| import React, { useState } from "react"; | ||
| import { | ||
| Dimensions, | ||
| Image, | ||
| KeyboardAvoidingView, | ||
| Keyboard, | ||
| StyleSheet, | ||
| Text, | ||
| } from "react-native"; | ||
| import { SafeAreaView } from "react-native-safe-area-context"; | ||
| import { router } from "expo-router"; | ||
| import { Button, TextInput, DismissKeyboard } from "../../components"; | ||
|
|
||
| const FishjamLogo = require("../../assets/images/fishjam-logo.png"); | ||
|
|
||
| export default function LivestreamScreen() { | ||
| const [connectionError, setConnectionError] = useState<string | null>(null); | ||
|
|
||
| const [fishjamId, setFishjamId] = useState( | ||
| process.env.EXPO_PUBLIC_FISHJAM_ID ?? "", | ||
| ); | ||
| const [roomName, setRoomName] = useState(""); | ||
|
|
||
| const validateInputs = () => { | ||
| if (!fishjamId) { | ||
| throw new Error("Fishjam ID is required"); | ||
| } | ||
|
|
||
| if (!roomName) { | ||
| throw new Error("Room name is required"); | ||
| } | ||
| }; | ||
|
|
||
| const onTapConnectViewerButton = async () => { | ||
| try { | ||
| validateInputs(); | ||
| setConnectionError(null); | ||
| Keyboard.dismiss(); | ||
| router.push({ | ||
| pathname: "/livestream/viewer", | ||
| params: { fishjamId, roomName }, | ||
| }); | ||
| } catch (e) { | ||
| const message = | ||
| "message" in (e as Error) ? (e as Error).message : "Unknown error"; | ||
| setConnectionError(message); | ||
| } | ||
| }; | ||
|
|
||
| const onTapConnectStreamerButton = async () => { | ||
| try { | ||
| validateInputs(); | ||
| setConnectionError(null); | ||
| Keyboard.dismiss(); | ||
| router.push({ | ||
| pathname: "/livestream/streamer", | ||
| params: { fishjamId, roomName }, | ||
| }); | ||
| } catch (e) { | ||
| const message = | ||
| "message" in (e as Error) ? (e as Error).message : "Unknown error"; | ||
| setConnectionError(message); | ||
| } | ||
| }; | ||
|
|
||
| const onTapConnectScreenSharingButton = async () => { | ||
| try { | ||
| validateInputs(); | ||
| setConnectionError(null); | ||
| Keyboard.dismiss(); | ||
| router.push({ | ||
| pathname: "/livestream/screen-sharing", | ||
| params: { fishjamId, roomName }, | ||
| }); | ||
| } catch (e) { | ||
| const message = | ||
| "message" in (e as Error) ? (e as Error).message : "Unknown error"; | ||
| setConnectionError(message); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <DismissKeyboard> | ||
| <SafeAreaView style={styles.safeArea}> | ||
| <KeyboardAvoidingView behavior="height" style={styles.container}> | ||
| {connectionError && ( | ||
| <Text style={styles.errorMessage}>{connectionError}</Text> | ||
| )} | ||
| <Image | ||
| style={styles.logo} | ||
| source={FishjamLogo} | ||
| resizeMode="contain" | ||
| /> | ||
| <TextInput | ||
| onChangeText={setFishjamId} | ||
| placeholder="Fishjam ID" | ||
| defaultValue={fishjamId} | ||
| /> | ||
| <TextInput | ||
| onChangeText={setRoomName} | ||
| placeholder="Room Name" | ||
| defaultValue={roomName} | ||
| /> | ||
| <Button | ||
| title="Connect to Livestream" | ||
| onPress={onTapConnectViewerButton} | ||
| /> | ||
| <Button | ||
| title="Stream Livestream" | ||
| onPress={onTapConnectStreamerButton} | ||
| /> | ||
| <Button | ||
| title="Stream Screen Sharing" | ||
| onPress={onTapConnectScreenSharingButton} | ||
| /> | ||
| </KeyboardAvoidingView> | ||
| </SafeAreaView> | ||
| </DismissKeyboard> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| safeArea: { | ||
| flex: 1, | ||
| backgroundColor: "#BFE7F8", | ||
| }, | ||
| container: { | ||
| flex: 1, | ||
| justifyContent: "center", | ||
| backgroundColor: "#BFE7F8", | ||
| padding: 20, | ||
| gap: 24, | ||
| }, | ||
| errorMessage: { | ||
| color: "black", | ||
| textAlign: "center", | ||
| margin: 25, | ||
| fontSize: 20, | ||
| }, | ||
| logo: { | ||
| width: Dimensions.get("window").width - 40, | ||
| }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.