Giter VIP home page Giter VIP logo

mqtt-client-framework's Introduction

MQTT-Client-Framework

Build Status codecov CocoaPods Version Platform BrowserStack Status

MQTT-Client-Framework is a native Objective-C iOS library. It uses CFNetwork for networking and CoreData for persistence. It is a complete implementation of MQTT 3.1.1 and supports TLS.

You can read introduction to learn more about framework.

MQTT-Client-Framework is tested with a long list of brokers:

  • mosquitto
  • paho
  • rabbitmq
  • hivemq
  • rsmb
  • mosca
  • vernemq
  • emqtt
  • moquette
  • ActiveMQ
  • Apollo
  • CloudMQTT
  • aws
  • hbmqtt (MQTTv311 only, limitations)
  • aedes
  • flespi

Usage

For example app, see MQTTChat

Create a new client and connect to a broker:

#import "MQTTClient.h"

MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init];
transport.host = @"test.mosquitto.org";
transport.port = 1883;
    
MQTTSession *session = [[MQTTSession alloc] init];
session.transport = transport;
[session connectWithConnectHandler:^(NSError *error) {
	// Do some work
}];

Subscribe to a topic:

[session subscribeToTopic:@"example/#" atLevel:MQTTQosLevelExactlyOnce subscribeHandler:^(NSError *error, NSArray<NSNumber *> *gQoss) {
    if (error) {
        NSLog(@"Subscription failed %@", error.localizedDescription);
    } else {
        NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss);
    }
 }];

In your MQTTSession delegate, add the following to receive messages for the subscribed topics:

- (void)newMessage:(MQTTSession *)session data:(NSData *)data onTopic:(NSString *)topic qos:(MQTTQosLevel)qos retained:(BOOL)retained mid:(unsigned int)mid {
    // New message received in topic
}

Publish a message to a topic:

[session publishData:someData onTopic:@"example/#" retain:NO qos:MQTTQosLevelAtMostOnce publishHandler:^(NSError *error) {
}];

If you already have a self signed URL from broker like AWS IoT endpoint, use the url property of MQTTWebsocketTransport:

MQTTWebsocketTransport *transport = [[MQTTWebsocketTransport alloc] init];
transport.url = @"wss://aws.iot-amazonaws.com/mqtt?expiry='2018-05-01T23:12:32.950Z'"

MQTTSession *session = [[MQTTSession alloc] init];
session.transport = transport;
[session connectWithConnectHandler:^(NSError *error) {
    // Do some work
}];

Installation

CocoaPods

Add this to your Podfile:

pod 'MQTTClient'

which is a short for:

pod 'MQTTClient/Min'
pod 'MQTTClient/Manager'

The Manager subspec includes the MQTTSessionManager class.

If you want to use MQTT over Websockets:

pod 'MQTTClient/Websocket'

If you want to do your logging with CocoaLumberjack (recommended):

pod 'MQTTClient/MinL'
pod 'MQTTClient/ManagerL'
pod 'MQTTClient/WebsocketL'

Carthage

In your Cartfile:

github "novastone-media/MQTT-Client-Framework"

Manually

Git submodule

  1. Add MQTT-Client-Framework as a git submodule into your top-level project directory or simply copy whole folder
  2. Find MQTTClient.xcodeproj and drag it into the file navigator of your app project.
  3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  4. Under "General" panel go to "Linked Frameworks and Libraries" and add MQTTClient.framework

Framework

  1. Download MQTT-Client-Framework
  2. Build it and you should find MQTTClient.framework under "Products" group.
  3. Right click on it and select "Show in Finder" option.
  4. Just drag and drop MQTTClient.framework to your project

Security Disclosure

If you believe you have identified a security vulnerability with MQTT-Client-Framework, please report it to [email protected] and do not post it to a public issue tracker.

Thanks

This project was originally written by Christoph Krey.

mqtt-client-framework's People

Contributors

adrxx avatar alasmanis avatar anagromataf avatar aterribili avatar bobwenx avatar carllee avatar ckrey avatar cooperrs avatar danielevans avatar devashishmamgain avatar e1t0n avatar felixlam avatar iyuna avatar jakesc avatar jcavar avatar kirillyakimovich avatar kprofic avatar lilhinx avatar mark2b avatar marotan3 avatar matsukaz avatar mendirattanishant avatar mwingbermuhle avatar mycoboco avatar ogres avatar omidid avatar pahakorolev avatar rift-walker avatar rndmtsk avatar robnadin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.