Skip to content

Commit 4a06e00

Browse files
authored
Merge pull request #99 from sendbird/feat/user-agent-revamp
chore(CLNP-204): user-agent revamp
2 parents 53b7928 + a657d43 commit 4a06e00

File tree

9 files changed

+54
-20
lines changed

9 files changed

+54
-20
lines changed

docs-validation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@react-native-firebase/messaging": "^14.7.0",
1616
"@react-navigation/native": "^6.0.6",
1717
"@react-navigation/native-stack": "^6.7.0",
18-
"@sendbird/chat": "^4.9.2",
18+
"@sendbird/chat": "^4.9.8",
1919
"react": "17.0.2",
2020
"react-native": "0.67.5",
2121
"react-native-create-thumbnail": "^1.5.1",

packages/uikit-chat-hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"typescript": "4.9.4"
5555
},
5656
"peerDependencies": {
57-
"@sendbird/chat": "^4.9.2",
57+
"@sendbird/chat": "^4.9.8",
5858
"react": ">=16.13.1"
5959
},
6060
"react-native-builder-bob": {

packages/uikit-react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"@react-native-clipboard/clipboard": ">=1.8.5",
106106
"@react-native-community/netinfo": ">=9.3.0",
107107
"@react-native-firebase/messaging": ">=14.4.0",
108-
"@sendbird/chat": "^4.9.2",
108+
"@sendbird/chat": "^4.9.8",
109109
"@sendbird/react-native-scrollview-enhancer": "*",
110110
"date-fns": ">=2.28.0",
111111
"expo-av": ">=12.0.4",

packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
22
import { Platform } from 'react-native';
33
import { SafeAreaProvider } from 'react-native-safe-area-context';
44

5-
import Sendbird from '@sendbird/chat';
5+
import Sendbird, { DeviceOsPlatform, SendbirdPlatform, SendbirdProduct } from '@sendbird/chat';
66
import { GroupChannelModule } from '@sendbird/chat/groupChannel';
77
import { OpenChannelModule } from '@sendbird/chat/openChannel';
88
import type { HeaderStyleContextType, UIKitTheme } from '@sendbird/uikit-react-native-foundation';
@@ -169,13 +169,11 @@ const SendbirdUIKitContainer = ({
169169
}
170170

171171
return () => {
172-
if (!isFirstMount) {
173-
unsubscribes.current.forEach((u) => {
174-
try {
175-
u();
176-
} catch {}
177-
});
178-
}
172+
unsubscribes.current.forEach((u) => {
173+
try {
174+
u();
175+
} catch {}
176+
});
179177
};
180178
}, [appId, internalStorage]);
181179

@@ -288,7 +286,17 @@ const initializeSendbird = (
288286
chatSDK = onInitialized(chatSDK);
289287
}
290288

291-
if (SendbirdUIKit.VERSION) {
289+
const platform = getDeviceOSPlatform();
290+
if (SendbirdUIKit.VERSION && platform) {
291+
const deviceOSInfo = { platform, version: String(Platform.Version) };
292+
const customData = { platform_version: getReactNativeVersion() };
293+
const uikitExtension = {
294+
product: SendbirdProduct.UIKIT_CHAT,
295+
version: SendbirdUIKit.VERSION,
296+
platform: SendbirdPlatform.REACT_NATIVE,
297+
};
298+
299+
chatSDK.addSendbirdExtensions([uikitExtension], deviceOSInfo, customData);
292300
chatSDK.addExtension('sb_uikit', SendbirdUIKit.VERSION);
293301
}
294302

@@ -331,4 +339,24 @@ const initializeSendbird = (
331339
return { chatSDK, unsubscribes };
332340
};
333341

342+
function getDeviceOSPlatform() {
343+
switch (Platform.OS) {
344+
case 'android':
345+
return DeviceOsPlatform.ANDROID;
346+
case 'ios':
347+
return DeviceOsPlatform.IOS;
348+
case 'web':
349+
return DeviceOsPlatform.WEB;
350+
case 'windows':
351+
return DeviceOsPlatform.WINDOWS;
352+
default:
353+
return undefined;
354+
}
355+
}
356+
357+
function getReactNativeVersion() {
358+
const { major, minor, patch } = Platform.constants.reactNativeVersion;
359+
return `${major}.${minor}.${patch}`;
360+
}
361+
334362
export default SendbirdUIKitContainer;

packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useState } from 'react';
1+
import React, { useCallback, useEffect, useState } from 'react';
22

33
import { useAppFeatures } from '@sendbird/uikit-chat-hooks';
44
import { SBUConfig, useUIKitConfig } from '@sendbird/uikit-tools';
@@ -144,6 +144,12 @@ export const SendbirdChatProvider = ({
144144
else if (status === 'background') sdkInstance.connectionState === 'OPEN' && sdkInstance.setBackgroundState();
145145
});
146146

147+
useEffect(() => {
148+
return () => {
149+
sdkInstance.disconnect().then(() => _setCurrentUser(undefined));
150+
};
151+
}, [sdkInstance]);
152+
147153
const value: SendbirdChatContextType = {
148154
sdk: sdkInstance,
149155
emojiManager,

packages/uikit-testing-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"access": "public"
3939
},
4040
"devDependencies": {
41-
"@sendbird/chat": "^4.9.2",
41+
"@sendbird/chat": "^4.9.8",
4242
"@sendbird/uikit-utils": "3.0.4",
4343
"@types/jest": "^29.4.0",
4444
"@types/react": "*",

packages/uikit-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"typescript": "4.9.4"
5656
},
5757
"peerDependencies": {
58-
"@sendbird/chat": "^4.9.2",
58+
"@sendbird/chat": "^4.9.8",
5959
"react": ">=17.0.2",
6060
"react-native": ">=0.65.0"
6161
},

sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@react-navigation/bottom-tabs": "^6.2.0",
2929
"@react-navigation/native": "^6.0.6",
3030
"@react-navigation/native-stack": "^6.7.0",
31-
"@sendbird/chat": "^4.9.2",
31+
"@sendbird/chat": "^4.9.8",
3232
"@sendbird/react-native-scrollview-enhancer": "^0.2.1",
3333
"@storybook/addon-actions": "^6.4.19",
3434
"@storybook/addon-controls": "^6.4.19",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,7 @@
32963296
dependencies:
32973297
nanoid "^3.1.23"
32983298

3299-
"@sendbird/[email protected]", "@sendbird/chat@^4.9.2":
3299+
"@sendbird/[email protected]", "@sendbird/chat@^4.9.8":
33003300
version "4.9.8"
33013301
resolved "https://registry.yarnpkg.com/@sendbird/chat/-/chat-4.9.8.tgz#c70378fc1da684ea0c532b2e55bd8b1f3939838c"
33023302
integrity sha512-tRTr/5iXl4Fhxon6T8yO2xaRxvyO2KctFjqdEHVLW9JuhWEAWiWZsY/5Lbxivi/Pt+ebiQuBhl/af3V1WOJDCg==
@@ -3307,9 +3307,9 @@
33073307
integrity sha512-LN+Tm+ZUkE2MBVreg/JI8SVr8SOKRteZN0YFpGzRtbKkP45+pKyPN4JQPf73eFx7qO8zDL+TUVyzz/1MOnIK7g==
33083308

33093309
"@sendbird/uikit-tools@^0.0.1-alpha.38":
3310-
version "0.0.1-alpha.38"
3311-
resolved "https://registry.yarnpkg.com/@sendbird/uikit-tools/-/uikit-tools-0.0.1-alpha.38.tgz#7f4122ef07906f18d039f12291d617a54246a3f9"
3312-
integrity sha512-E/8DCnhGfLev/xbNwsR30E/HU7ylvDvxWl/mcka1R96DYSNc8x/G7IHI4F6q/1lZ6jdYof61jdHb/r5vPTeQug==
3310+
version "0.0.1-alpha.39"
3311+
resolved "https://registry.yarnpkg.com/@sendbird/uikit-tools/-/uikit-tools-0.0.1-alpha.39.tgz#1982e2e9d752779d0229fee39349fbac25836f92"
3312+
integrity sha512-hHHeYXEF8my7EfX/jkLfC7iWo1G7GKITL6ZMA3rw2AIHbCTuoF+qzB9r5sE1KZYkXDL4spsZDP7FXv2fqGRyiw==
33133313

33143314
"@sideway/address@^4.1.3":
33153315
version "4.1.4"

0 commit comments

Comments
 (0)