Skip to main content

Messages

Send requests and events from a Lens on SPECS to the connected mobile app with Mobile Kit, and subscribe to events the app pushes.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported
  • SPECSFully supported
  • Camera Kit WebNot supported
  • Camera Kit MobileNot supported

Platform details

  • Snapchat — Not supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported.

  • Camera Kit Mobile — Not supported.

Send Requests

Use sendRequest() to send a message to the connected mobile app and wait for a response.

try {
const response = await session.sendRequest('hello world!')
print(`Response: ${response}`)
} catch (error) {
print(`Error: ${error}`)
}

Send Events

Use sendData() to send a one-way message to the connected mobile app. This is a fire-and-forget operation, no response is expected.

session.sendData('A Event!')

Subscribe Events

Lens can subscribe to events pushed from the connected mobile app using startSubscription().

// subscribe to a topic
const subscription = session.startSubscription(
'Topic-1',
(error) => {
print(`Subscription error: ${error}`)
}
)

subscription.add((event) => {
print(`Subscription event: ${event}`)
})