Skip to content

IoT SDK Integration Guide

Feature Description

QuecIotSdk serves as the entry SDK for IoT SDK, enabling development based on public cloud or private deployments.

This SDK helps developers rapidly complete app development because developers only need to focus on UI/UE design, while ignoring complex protocols and error management.

Key features:

  • Initialize the SDK (This step must be completed before user, device, home, and other functionalities are used).
  • Enable debug mode to print logs for issue analysis.
  • Set the country code to get global domain routing services data.
  • Get country list data.

SDK Integration

Step 1: Register an Developer Center Account

Before using Developer Center, you need to access https://aiot.quectel.com/ to register an account

Step 2: Integrate SDK

Via CocoaPods

The current SDK supports iOS 13.0 and above.

  1. Update CocoaPods to the latest version. Refer to CocoaPods official documents for the CocoaPods usage.
  2. Add the following content in the Podfile file.
objc
source 'https://github.com/thridparty-cloud2/QuecPublicSpecs.git'

platform :ios, '13.0'
target 'Your_Project_Name' do
    use_frameworks!
    pod "QuecIotSdk", '~> 2.0.0'
    
end
  1. In the project's root directory, execute pod update to integrate the SDK.

Via Download

  1. Obtain the SDK resources from the Download Center.
  2. Double-click the downloaded package to unzip it. Add the static libraries and resource files from the extracted folder to your project. img
  3. Add system dependency libraries.
  • libc++.tbd
  • CoreTelephony.framework
  • libz.tbd
  • SystemConfiguration.framework
  • libresolv.9.tbd
  1. Integrate third-party libraries (CocoaPods integration requires use_frameworks! configuration).
  • AFNetworking (4.0)
  • YYModel (1.0.4)
  • SocketRocket (0.6.0)
  • CocoaAsyncSocket (7.6.5)
  1. Navigate to "TARGETS" – "QuecTestSDK" – "Build Settings" – "Other Linker Flags" and add "-ObjC".
  2. Enable Swift-OC mixed compilation (Create a Swift file in your project. Xcode will automatically generate a XXX-Bridge-Header.h file).

Step 3: Configure userDomain and userDomainSecret

Obtain userDomain and userDomainSecret by creating an app in the Developer Center.

img

img

Step 4: Initialize the SDK

API

Initialize the SDK with the user domain, secret, and cloud service type to connect to the public cloud's China, Europe, or North America services.

objc
- (void)startWithUserDomain:(NSString *)userDomain
           userDomainSecret:(NSString *)userDomainSecret
           cloudServiceType:(QuecCloudServiceType)cloudServiceType;

Parameter

ParameterRequiredDescription
userDomainYUser domain, generated when an app is created on Developer Center.
userDomainSecretYUser domain secret, generated when an app is created on Developer Center.
cloudServiceTypeYCloud service type, used to specify the service region to connect to.

QuecCloudServiceTypeEnumeration Definition

objc
typedef NS_ENUM(NSUInteger, QuecCloudServiceType) { //Cloud service type.
    QuecCloudServiceTypeChina = 0, //China
    QuecCloudServiceTypeEurope,    //Europe
    QuecCloudServiceTypeNorthAmerica,    //North America
};

Example

objc
[QuecIoTAppSDK.sharedInstance startWithUserDomain:@"your userDomain" userDomainSecret:@"your domainSecret" cloudServiceType:QuecCloudServiceTypeChina];

Initialize Private Deployment

API

Initialize private deployment so that users can configure information such as cloud service URLs and domain routing data for SDK access.

objc
- (void)startWithConfig:(QuecPublicConfig *)config;

Parameter

ParameterRequiredDescription
configYInitialization configuration template.

QuecPublicConfig Definition

FieldTypeDescription
userDomainNSStringUser domain (required)
userDomainSecretNSStringUser domain secret (required)
baseUrlNSStringRequest URL (required)
webSocketUrlNSStringWebSocket 1.0 URL (required)
webSocketV2UrlNSStringWebSocket 2.0 URL (required)
bootstrapUrlNSStringDomain routing service URL (required)
bootstrapPathNSStringDomain routing path (required)
bootstrapTokenNSStringDomain routing key (required)
mccNSStringMCC (optional)
tcpAddrNSStringTCP address (optional)
pskAddrNSStringPSK address (optional)
tlsAddrNSStringTLS address (optional)
cerAddrNSStringCER address (optional)
reportAddrNSStringBluetooth data report URL (optional)

Example

objc
QuecPublicConfig *iotConfig = QuecPublicConfig.new;
iotConfig.userDomain = @"X.XX.XXXX.X";
iotConfig.userDomainSecret = @"XXXXXXXXXXXXXXXXXXXXXXXX";
iotConfig.baseUrl = @"https://xxx.com";
iotConfig.webSocketUrl = @"xxx://xxx.com/xx";
iotConfig.webSocketV2Url = @"xxx://xxx.com:xxxx/xx";
iotConfig.bootstrapUrl = @"https://xxx.com";
iotConfig.bootstrapPath = @"/xxx";
iotConfig.bootstrapToken = @"xxx";
[QuecIoTAppSDK.sharedInstance startWithConfig:iotConfig]

Enable/Disable Debug Mode

API

Enable or disable debug mode. During development, you can enable debug mode to print logs for issue analysis.

objc
- (void)setDebugMode:(BOOL)debugMode;

Parameter

ParameterRequiredDescription
debugModeYEnable or disable debug mode.

Example

objc
[QuecIoTAppSDK.sharedInstance setDebugMode:YES];

Set Country Code

API

Configure the country code to retrieve MCC-based domain routing services.

objc
- (void)setCountryCode:(NSString *)countryCode;

Parameter

ParameterRequiredDescription
countryCodeYCountry code (e.g., "86" for China)

Example

objc
[QuecIoTAppSDK.sharedInstance setCountryCode:@"86"];

Get Country List

API

Get the list of public-cloud-supported countries (SDK initialization is required first).

objc
- (NSArray<QuecCountryInfoModel *> *)getCountryData;

Parameter

QuecCountryInfoModel Definition

FieldTypeDescription
nameNSStringCountry name.
internationalCodeNSStringCountry code (e.g., "86")

Example

objc
NSArray<QuecCountryInfoModel *> *countrys = [QuecIoTAppSDK.sharedInstance getCountryData];
if (countrys.count) {
    /// Next Action
}