Skip to content

Commit 6129cbe

Browse files
committed
chore: add uikit extension
1 parent 53b7928 commit 6129cbe

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

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

Lines changed: 32 additions & 2 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';
@@ -288,7 +288,17 @@ const initializeSendbird = (
288288
chatSDK = onInitialized(chatSDK);
289289
}
290290

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

@@ -331,4 +341,24 @@ const initializeSendbird = (
331341
return { chatSDK, unsubscribes };
332342
};
333343

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

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)