Skip to content

Commit 8eaad25

Browse files
authored
Merge pull request #42 from sendbird/feat/chat-v4
[UIKIT-1973] Feat/migration to chat v4
2 parents 3bfe517 + 1d208ac commit 8eaad25

File tree

125 files changed

+3319
-810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+3319
-810
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ ios
55
.eslintrc.js
66
**/*.config.js
77
**/scripts/*.js
8+
docs-validation/*

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs-validation/*
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import React from 'react';
2+
3+
import type { FileType } from '@sendbird/uikit-react-native';
4+
const PROFILE_FILE: FileType = { name: '', size: 0, type: '', uri: '' };
5+
6+
/**
7+
* Connect to the Sendbird server
8+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-connect-to-the-sendbird-server}
9+
* */
10+
import { useConnection } from '@sendbird/uikit-react-native';
11+
12+
const Component = () => {
13+
const { connect } = useConnection();
14+
15+
connect('USER_ID', { nickname: 'NICKNAME', accessToken: 'ACCESS_TOKEN' })
16+
.then((_user) => {
17+
// 1. The user is online and connected to the server.
18+
// 2. The user is offline but you can access user information stored
19+
// in the local cache.
20+
})
21+
.catch((_err) => {
22+
// The user is offline and you can't access any user information stored
23+
// in the local cache.
24+
});
25+
};
26+
/** ------------------ **/
27+
28+
/**
29+
* Disconnect from the Sendbird server
30+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-disconnect-from-the-sendbird-server}
31+
* */
32+
const Component2 = () => {
33+
const { disconnect } = useConnection();
34+
disconnect();
35+
}
36+
/** ------------------ **/
37+
38+
/**
39+
* Retrieve online status of current user
40+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-retrieve-online-status-of-current-user}
41+
* */
42+
import { useSendbirdChat } from '@sendbird/uikit-react-native';
43+
44+
const Component3 = () => {
45+
const { currentUser } = useSendbirdChat();
46+
47+
if (currentUser) {
48+
// User is online.
49+
} else {
50+
// User is offline.
51+
}
52+
}
53+
/** ------------------ **/
54+
55+
/**
56+
* Register for push notifications
57+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-register-for-push-notifications}
58+
* */
59+
import RNFBMessaging from '@react-native-firebase/messaging';
60+
import * as Permissions from 'react-native-permissions';
61+
import { SendbirdUIKitContainer, createNativeNotificationService } from '@sendbird/uikit-react-native';
62+
63+
const NotificationService = createNativeNotificationService({
64+
messagingModule: RNFBMessaging,
65+
permissionModule: Permissions,
66+
});
67+
68+
const App = () => {
69+
return (
70+
<SendbirdUIKitContainer
71+
// @ts-ignore
72+
platformServices={{ notification: NotificationService }}
73+
/>
74+
);
75+
};
76+
/** ------------------ **/
77+
78+
/**
79+
* Unregister push notifications
80+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-unregister-push-notifications}
81+
* */
82+
const App2 = () => {
83+
return (
84+
// @ts-ignore
85+
<SendbirdUIKitContainer
86+
chatOptions={{ enableAutoPushTokenRegistration: false }}
87+
/>
88+
);
89+
};
90+
/** ------------------ **/
91+
92+
/**
93+
* Update user profile
94+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/authentication#2-update-user-profile}
95+
* */
96+
const Component4 = () => {
97+
const { updateCurrentUserInfo } = useSendbirdChat();
98+
99+
const update = async () => {
100+
const updatedUserWithUrl = await updateCurrentUserInfo('NICKNAME', 'PROFILE_URL');
101+
102+
// Or you can update the profile image file.
103+
const updatedUserWithFile = await updateCurrentUserInfo('NICKNAME', PROFILE_FILE);
104+
}
105+
}
106+
/** ------------------ **/
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import {
2+
createExpoClipboardService,
3+
createExpoFileService,
4+
createExpoMediaService,
5+
createExpoNotificationService,
6+
createNativeClipboardService,
7+
createNativeFileService,
8+
createNativeMediaService,
9+
createNativeNotificationService,
10+
} from '@sendbird/uikit-react-native';
11+
12+
/**
13+
* Helper functions#React Native CLI
14+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/native-modules#2-helper-functions-3-react-native-cli}
15+
* */
16+
import Clipboard from '@react-native-clipboard/clipboard';
17+
import CameraRoll from '@react-native-community/cameraroll';
18+
import RNFBMessaging from '@react-native-firebase/messaging';
19+
import Video from 'react-native-video';
20+
import * as DocumentPicker from 'react-native-document-picker';
21+
import * as FileAccess from 'react-native-file-access';
22+
import * as ImagePicker from 'react-native-image-picker';
23+
import * as Permissions from 'react-native-permissions';
24+
import * as CreateThumbnail from 'react-native-create-thumbnail';
25+
26+
const NativeClipboardService = createNativeClipboardService(Clipboard);
27+
const NativeNotificationService = createNativeNotificationService({
28+
messagingModule: RNFBMessaging,
29+
permissionModule: Permissions,
30+
});
31+
const NativeFileService = createNativeFileService({
32+
fsModule: FileAccess,
33+
permissionModule: Permissions,
34+
imagePickerModule: ImagePicker,
35+
mediaLibraryModule: CameraRoll,
36+
documentPickerModule: DocumentPicker,
37+
});
38+
const NativeMediaService = createNativeMediaService({
39+
VideoComponent: Video,
40+
thumbnailModule: CreateThumbnail,
41+
});
42+
/** ------------------ **/
43+
44+
/**
45+
* Helper functions#Expo CLI
46+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/native-modules#2-helper-functions-3-expo-cli}
47+
* */
48+
import * as ExpoClipboard from 'expo-clipboard';
49+
import * as ExpoDocumentPicker from 'expo-document-picker';
50+
import * as ExpoFS from 'expo-file-system';
51+
import * as ExpoImagePicker from 'expo-image-picker';
52+
import * as ExpoMediaLibrary from 'expo-media-library';
53+
import * as ExpoNotifications from 'expo-notifications';
54+
import * as ExpoAV from 'expo-av';
55+
import * as ExpoVideoThumbnail from 'expo-video-thumbnails';
56+
57+
const ExpoNotificationService = createExpoNotificationService(ExpoNotifications);
58+
const ExpoClipboardService = createExpoClipboardService(ExpoClipboard);
59+
const ExpoFileService = createExpoFileService({
60+
fsModule: ExpoFS,
61+
imagePickerModule: ExpoImagePicker,
62+
mediaLibraryModule: ExpoMediaLibrary,
63+
documentPickerModule: ExpoDocumentPicker,
64+
});
65+
const ExpoMediaService = createExpoMediaService({
66+
avModule: ExpoAV,
67+
thumbnailModule: ExpoVideoThumbnail
68+
})
69+
/** ------------------ **/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
3+
const GroupChannelScreen = () => <React.Fragment />;
4+
5+
/**
6+
* Set up navigation in a fragment
7+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/screen-navigation#2-set-up-navigation-in-a-fragment}
8+
* */
9+
// @ts-ignore
10+
import { Navigation } from 'react-native-navigation';
11+
import { createGroupChannelListFragment } from '@sendbird/uikit-react-native';
12+
13+
const GroupChannelListFragment = createGroupChannelListFragment();
14+
15+
const GroupChannelListScreen = (props: { componentId: string }) => {
16+
return (
17+
<GroupChannelListFragment
18+
onPressCreateChannel={() => {
19+
// Navigate to create group channel screen.
20+
}}
21+
onPressChannel={(channel) => {
22+
// Navigate to group channel screen.
23+
Navigation.push(props.componentId, {
24+
component: {
25+
name: 'GroupChannel',
26+
passProps: { channel },
27+
},
28+
});
29+
}}
30+
/>
31+
);
32+
};
33+
/** ------------------ **/
34+
35+
/**
36+
* Integrate navigation library
37+
* {@link https://sendbird.com/docs/uikit/v3/react-native/introduction/screen-navigation#2-integrate-navigation-library}
38+
* */
39+
Navigation.registerComponent('GroupChannel', () => GroupChannelScreen);
40+
Navigation.registerComponent('GroupChannelList', () => GroupChannelListScreen);
41+
/** ------------------ **/

0 commit comments

Comments
 (0)