1.3.0-alpha.0 • Published 3 days ago

@expressms/smartapp-bridge v1.3.0-alpha.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 days ago

SmartApp bridge library

This library provides a universal interface for exchanging events with an express client. Andriod, iOS and Web clients supported.

All types can be found here.

Send event to eXpress

SmartAppBridge
  .sendClientEvent(
    {
      method: 'get_weather',
      params: {
        city: 'Moscow',
      },
      files: []
    }
  )
  .then(data => {
    // Handle response
    console.log('response', data)
  })
  .then(({ type: method, handler: express, payload: params, files }) => {
    // Handle response data type, payload
  })
  .catch(() => {
    // Do something on timeout
  })
SmartAppBridge
  .sendBotEvent(
    {
      method: 'get_weather',
      params: {
        city: 'Moscow',
      },
    }
  )
  .then(data => {
    // Handle response
    console.log('response', data)
  })
  .then(({ type: method, handler: botx, payload: params }) => {
    // Handle response data type, payload
  })
  .catch(() => {
    // Do something on timeout
  })

Receive event from eXpress

SmartAppBridge.onRecieve(({ type, payload }) => {
  // This callback triggers when eXpress client send data without ref
})

Enable/Disable renaming event params from camelCase to snake_case and vice versa

  • Params are renamed from camelCase to snake_case and vice versa by default
  • Call after sending ready event
SmartAppBridge.disableRenameParams()
SmartAppBridge.enableRenameParams()

Enable/disable logging smart app events

SmartAppBridge.enableLogs()
SmartAppBridge.disableLogs()

Logging via bridge on mobile devices

  • log your data inside a smart app:
  import { Bridge as bridge } from '@unlimited/smartapp-bridge'

  const data: string | value = { logs: 'test' }
  bridge?.log?.(data)
  • Search in mobile logs by 'SmartApp Log' string
SmartAppBridge?.log?.(data)
1.3.0-alpha.0

3 days ago

1.2.0

10 months ago

1.2.2-alpha

5 months ago

1.2.3-alpha1

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

10 months ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.1

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.0

2 years ago