diff --git a/package.json b/package.json index d532432..745e6bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@expressms/smartapp-sdk", - "version": "1.5.0", + "version": "1.6.0-alpha.0", "description": "Smartapp SDK", "main": "build/main/index.js", "typings": "build/main/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 7480e3d..c1cf584 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import { createDeeplink, getChats, getConnectionStatus, + handleDeeplink, openChatMessage, openClientSettings, openFile, @@ -72,4 +73,5 @@ export { clientStorageRemove, clientStorageClear, openPersonalChat, + handleDeeplink, } diff --git a/src/lib/client/index.ts b/src/lib/client/index.ts index 06d6e0b..c705355 100644 --- a/src/lib/client/index.ts +++ b/src/lib/client/index.ts @@ -1,10 +1,16 @@ import bridge from '@expressms/smartapp-bridge' import { EmitterEventPayload } from '@expressms/smartapp-bridge/build/main/types/eventEmitter' -import { CreateDeeplinkResponse, ERROR_CODES, File, GetConnectionStatusResponse, METHODS } from '../../types' +import { + CreateDeeplinkResponse, + ERROR_CODES, + File, + GetConnectionStatusResponse, + METHODS, + StatusResponse, +} from '../../types' export * from './events' export * from './storage' - const openClientSettings = () => { return bridge?.sendClientEvent({ method: METHODS.OPEN_CLIENT_SETTINGS, @@ -126,6 +132,22 @@ const openChatMessage = async ({ }) } +/** + * Handle deeplink to join call/conference/chat/channel + * @param deeplink Deeplink URL + * @returns Promise that'll be fullfilled with success response, otherwise rejected with reason + */ +const handleDeeplink = ({ deeplink }: { deeplink: string }): Promise => { + if (!bridge) return Promise.reject(ERROR_CODES.NO_BRIDGE) + + return bridge + .sendClientEvent({ + method: METHODS.HANDLE_DEEPLINK, + params: { deeplink }, + }) + .then(event => event as StatusResponse) +} + export { openFile, openClientSettings, @@ -137,4 +159,5 @@ export { getConnectionStatus, createDeeplink, openChatMessage, + handleDeeplink, } diff --git a/src/types/bridge.ts b/src/types/bridge.ts index 8bc270b..b730248 100644 --- a/src/types/bridge.ts +++ b/src/types/bridge.ts @@ -31,6 +31,7 @@ export enum METHODS { CLIENT_STORAGE_SET = 'client_storage_set', CLIENT_STORAGE_REMOVE = 'client_storage_remove', CLIENT_STORAGE_CLEAR = 'client_storage_clear', + HANDLE_DEEPLINK = 'handle_deeplink', } export enum STATUS {