PlatformServiceProvider
In order to use the APIs and features of the native module, you need to implement the platform service interfaces that Sendbird provides. Each interface comes with a set of methods and helper functions. The PlatformServiceProvider
component passes down the platform service interfaces to the child components so they can be applied across the UIKit.
List of platform service interfaces
Interface | Method | Helper function |
---|---|---|
NotificationServiceInterface | hasPushPermission | createNativeNotificationService |
ClipboardServiceInterface | setString | createNativeClipboardService |
FileServiceInterface | openMediaLibrary | createNativeFileService |
MediaServiceInterface | VideoComponent | createNativeMediaService |
NotificationServiceInterface
The following table lists the properties of NotificationServiceInterface
.
Property | Description |
---|---|
hasPushPermission(): Promise | Checks for push notification permission and returns either |
requestPushPermission(): Promise | Requests push notification permission and returns either |
getAPNSToken(): Promise<string/null> | Retrieves an APNS token and returns either the token string or |
getFCMToken(): Promise<string/null> | Retrieves a FCM token and returns either the token string or |
onTokenRefresh(handler: (token: string) => void): () => void / undefined | Refreshes the push token and returns the |
ClipboardServiceInterface
The following table lists the properties of ClipboardServiceInterface
.
Property | Description |
---|---|
setString(text: string): void | Saves text to clipboard. |
getString(): Promise | Retrieves text from clipboard. |
FileServiceInterface
See the code below on how to use the properties to send a file message.
Property | Description |
---|---|
openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<null/FilePickerResponse[]> | Opens the media library to retrieve a media file. This method returns the image file info. |
openCamera(options?: OpenCameraOptions): Promise | Opens the phone camera to retrieve a media file. This method returns the image file info. |
openDocument(options?: OpenDocumentOptions): Promise | Opens the document file library and retrieves a file. This method returns the file info. |
save(options: SaveOptions): Promise | Downloads a file to the mobile device and returns the download path. |
MediaServiceInterface
The following table lists the properties of MediaServiceInterface
.
Property | Description |
---|---|
VideoComponent(props: VideoProps): JSX.Element | Specifies a video component. |
getVideoThumbnail(options: GetVideoThumbnailOptions): void | Generates a thumbnail for the video. |
Usage
The platform service interfaces are set as properties of SendbirdUIKitContainer
and they can be applied to the entire Sendbird UIKit through PlatformServiceProvider
.
Once the interfaces are internally set in UIKit for React Native, they can be called when you need to use native APIs such as downloading a media file or sending an image.
Direct implementation
If you're already using a native module that isn't supported by Sendbird UIKit, you can implement the interfaces directly as shown in the code below.