Home About us Support Partners SIGN UP NOW

iOS MQTT Client Setup

Text Copied
Introduction

This documentation provides a thorough guide for integrating our CrystalMQ broker or any other MQTT broker with a mobile application on iOS. It covers essential tasks such as establishing connections, subscribing to topics, unsubscribing, and exchanging messages. By following these steps, you can smoothly implement MQTT communication within your mobile applications.

Requirements

Before you begin, make sure you have:

  • An iPhone or iPad with iOS
  • An MQTT broker of your choice
  • Any MQTT client app from the App Store (For this guide, we use IoT MQTT Panel as an example)
  • Active internet connectivity on your device
Downloading the Mobile App

Start by downloading and installing the IoT MQTT Panel app from the App Store:

  • Open the App Store on your iOS device.
  • Search for "IoT MQTT Panel" app.
  • Tap "Get" to download and install the app.

Steps to Connect the IoT MQTT Panel to an MQTT Broker

Step 1: Open the IoT MQTT Panel App

Once the app is installed, launch IoT MQTT Panel on your iOS device.

Step 2: Add a New Broker

  • On the app's main screen, tap "Setup a Connection" to create a new connection with your MQTT broker.
  • setup connection
  • Enter the following details:
    • Connection Name: Give a name to your broker connection (e.g., "Home MQTT Broker").
    • Client ID: Enter a unique client ID (e.g., iOSClient1). Each device connecting to the broker should have a unique ID.
    • Broker Web/IP Address: Input the hostname or IP address of your MQTT broker (e.g., crystalmq.bevywise.com).
    • Port: Specify the port number of the MQTT broker (default is 1883 for unencrypted communication or 8883 for encrypted communication).
    • Network Protocol: Choose the appropriate protocol (TCP, TCP-SSL, WebSocket, WebSocket-SSL) as required.
Network protocols list
TCP SSL
Websocket SSL

Step 3: Add Dashboard

Ensure at least one dashboard is set up to establish the connection:

  • Tap the '+' icon to open the 'Add Dashboard' window.
  • Add dashboard
  • Enter a name for your dashboard.
  • Tap "Save" to create the dashboard.

Step 4: Configure Additional Settings (Optional)

Tap on "Additional Options" to configure advanced settings:

Additional options
  • Username: Enter your broker's username if authentication is required.
  • Password: Provide the password associated with the username.
  • Auto Connect: Enable automatic reconnection after network disruptions.
  • Keep Alive: Adjust the keep-alive interval in seconds (default is 60).
  • Clean Session: Enable or disable clean session (default is enabled).
  • Last Will and Testament (LWT): Set up a message to be sent if the client disconnects unexpectedly.
  • Notify on Disconnect: Receive notifications when the client disconnects due to errors.

Step 5: Save and Connect

Once all details are entered, tap "Create" to save the connection settings. Tap on the newly created broker entry to initiate the connection.

Step 6: Add a Panel to Subscribe to Topics

After connecting to the broker, add panels to subscribe to topics and view messages:

  • Tap the '+' icon and select the panel type (e.g., Text Panel, Switch Panel).
  • Panel list
  • Configure the panel:
    • Name: Enter a name for the panel.
    • Topic: Specify the topic to subscribe to (e.g., home/temperature).
    • QoS: Set the Quality of Service level (default is 0).
  • Tap "Save" to add the panel.

Step 7: Publish Messages

To publish messages to a topic:

  • Navigate to the "Publish" tab.
  • Enter the topic and message payload.
  • Tap "Publish" to send the message.

You have now successfully connected the IoT MQTT Panel app on your iOS device to an MQTT broker. Begin subscribing to topics to receive messages and publishing messages to communicate with other devices or services in your IoT network.