Skip to content

Commit

Permalink
Add handleDeeplink method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Jan 29, 2024
1 parent 4307bb6 commit e49f9e4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createDeeplink,
getChats,
getConnectionStatus,
handleDeeplink,
openChatMessage,
openClientSettings,
openFile,
Expand Down Expand Up @@ -72,4 +73,5 @@ export {
clientStorageRemove,
clientStorageClear,
openPersonalChat,
handleDeeplink,
}
27 changes: 25 additions & 2 deletions src/lib/client/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<StatusResponse> => {
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,
Expand All @@ -137,4 +159,5 @@ export {
getConnectionStatus,
createDeeplink,
openChatMessage,
handleDeeplink,
}
1 change: 1 addition & 0 deletions src/types/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e49f9e4

Please sign in to comment.