mitter.io
  • Welcome
  • Migrating from cloud to on-prem
  • Get mitter.io
    • Custom configuration
  • Getting started
    • Build Your First Android App
      • Setup
      • Authenticate a User
      • Start a Basic Chat
      • Selective Deliveries
      • Custom Payloads
    • Build Your First iOS App
      • Overview
      • Installation
      • Basic Setup
      • Receive Push Messages
      • Storyboard
      • Channel List
      • Channel Window
    • Build Your First Web App
      • Setting Up Your App
      • Start a Basic Chat
      • Selective Deliveries
    • Build Your First React Native app
  • Platform Reference
    • Introduction
    • Concepts
    • Authorization and Access
    • Calling the APIs
    • Users
    • Channels
      • Channel Streams and Typing Indicators
    • Messages
    • Delivery Endpoints (Push Notifications)
    • Federated Authentication
    • Basic Permissions and Privileges
    • ACLs and Advanced Permission Model
    • Metadata
  • SDKs
    • Android
      • Getting Started
      • Set up FCM
      • Presence and Timeline Events
      • Profiles, Pagination and Locators
      • Using the UI Framework
    • iOS
      • Installation
      • Basic Setup
      • Get the current user details
      • Create a Channel
      • Messaging
      • Push Messages
    • Javascript
      • Using the UI framework (web only)
      • For react-native
      • For node.js
      • TSDocs / JSDocs
      • For Typescript Users
    • Java (Backend)
Powered by GitBook
On this page
  • Send a plain Text Message
  • Get messages in a channel
  1. SDKs
  2. iOS

Messaging

Send a plain Text Message

Sending a plain text message is really simple. Just call the sendTextMessage() function on the Mitter.Messaging instance and pass a channel ID and text payload.

                appDelegate.mitter.messaging.sendTextMessage(
                    forChannel: "rakfT-XPdJb-WsucS-Pxy4B",
                    "Hello from iOS!"
                ) { result in
                    switch result {
                    case .success:
                        print("Message sent!")
                    case .error:
                        print("Couldn't send message")
                    }
                } 

Here you can specify the channel ID that you got while creating a new channel in the previous step.

Run the project and it should send out a new message to the channel.

Get messages in a channel

You can get messages sent to a particular channel by calling the getMessagesInChannel() and passing in the channel ID:

appDelegate.mitter.messaging.getMessagesInChannel("rakfT-XPdJb-WsucS-Pxy4B") {
            result in
            switch result {
            case .success(let messages):
                print("Messages: \(messages)")
            case .error:
                print("Couldn't fetch messages")
            }
        }

Run the project and you should be getting a list of messages printed to your console log.

PreviousCreate a ChannelNextPush Messages

Last updated 6 years ago