CreateBlogSupport
Log inSign up
Home
Webex Messaging
  • Overview
  • Guides
  • REST API Basics
  • API REFERENCE
  • All APIs
  • Changelog
  • SDK
  • AI Assistant for Developers
  • Widgets
  • Tutorials
  • Suite Sandbox
  • Beta Program
  • Webex Status API
  • XML API Deprecation

Webex Messaging

Quickstart

This article provides examples of common methods used in the meetings flow for the iOS Messaging SDK. For detailed method parameters, refer to the SDK API Reference.

The Webex instance is the primary entry point for the SDK, allowing access to all Webex SDK APIs.

anchorCreate a New Webex Space

anchor

To create a new Webex space:

webex.spaces.create("Hello World", null, CompletionHandler<Space?> { result ->
    if (result.isSuccessful) {
        val space = result.data
    } else {
        val error= result.error
    }
})

anchorAdd a User to a Space

anchor

To add a user to a space:

webex.memberships.create(space.id, null, "person@example.com", true, CompletionHandler<Membership?> { result ->
    if (result.isSuccessful) {
        val space = result.data
    } else {
        val error= result.error
    }
})
Post a Message in a Space

To post a message in the space:

webex.messages.postToSpace(space.id, Message.Text.plain("Hello"), null, null, CompletionHandler<Message> { result ->
    if(result != null && result.isSuccessful){
        val message = result.data
    }
})

anchorPost a Message with an Attachment

anchor

To post a message to a space with an attachment:


// targetId is the spaceId or personId or email address

webex.messages.post(targetId, Message.draft(Message.Text.markdown("**Hello**", null, null)).addAttachments(localFile), CompletionHandler { result ->
    if (result.isSuccessful) {
        // message sent successfully
    } else {
        val error = result.error
        // message sent failed
    }
})

anchorPost a Message as a Reply to a Thread

anchor

To post a message as a reply to a thread:

webex.messages.post(targetId, Message.draft(Message.Text.markdown("**Hello**", null, null))
.addAttachments(localFile)
.setParent(parentMessage),
CompletionHandler { result ->
    if (result.isSuccessful) {
        // message sent successfully
    } else {
        val error = result.error
        // message sent failed
    }
})

anchorIntercept Messaging Events

anchor

To intercept messaging events:

webex.messages.setMessageObserver(object : MessageObserver {
    override fun onEvent(event: MessageObserver.MessageEvent) {
        when (event) {
            is MessageObserver.MessageReceived -> {
                val message = event.getMessage()
                if (message?.getParentId() != null) {
                    // Threaded message
                }
            }
            is MessageObserver.MessageDeleted -> {
                // message deleted
            }
            is MessageObserver.MessageFileThumbnailsUpdated -> {
                // thumbnails updated for files
            }
            is MessageObserver.MessageEdited -> {
                // message edited successfully. event.getMessage() returns the edited message.
            }
        }
    }
})

anchorManage the Background Connection

anchor

To maintain a websocket connection in the background (allowing background syncing of messages):

webex.phone.enableBackgroundConnection(enable: Boolean)

anchorEnable or Disable Console Logging

anchor

To enable/disable console login:

webex.enableConsoleLogger(enable: Boolean)

anchorSet the Log Level

anchor

To set the current log level:

webex.setLogLevel(logLevel: LogLevel)

anchorCheck Feature Entitlements for a Logged-In User

anchor

To determine what entitlements a particular logged-in user has:

var capability = webex.people.getProductCapability()

var hasCalling = capability.isCallingSupported()
var hasMessaging = capability.isMessagingSupported()
var hasMeeting = capability.isMeetingSupported()
In This Article
  • Create a New Webex Space
  • Add a User to a Space
  • Post a Message with an Attachment
  • Post a Message as a Reply to a Thread
  • Intercept Messaging Events
  • Manage the Background Connection
  • Enable or Disable Console Logging
  • Set the Log Level
  • Check Feature Entitlements for a Logged-In User

Connect

Support

Developer Community

Developer Events

Contact Sales

Handy Links

Webex Ambassadors

Webex App Hub

Resources

Open Source Bot Starter Kits

Download Webex

DevNet Learning Labs

Terms of Service

Privacy Policy

Cookie Policy

Trademarks

© 2025 Cisco and/or its affiliates. All rights reserved.