AWSIoTDataManager

Objective-C

@interface AWSIoTDataManager : AWSService

/**
 The service configuration used to instantiate this service client.

 @warning Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.
 */
@property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration;

/**
 The MQTT configuration used by this service client. Any changes to this configuration object 
 will take effect upon the next invocation of either the connectWithClientId or connectUsingWebSocketWithClientId
 methods.
 
 */
@property (nonatomic, strong, readonly) AWSIoTMQTTConfiguration *mqttConfiguration;

/**
 Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with `defaultServiceConfiguration` from `[AWSServiceManager defaultServiceManager]`. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

 For example, set the default service configuration in `- application:didFinishLaunchingWithOptions:`

 *Swift*

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
         let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
         let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
         AWSServiceManager.default().defaultServiceConfiguration = configuration

         return true
     }

 *Objective-C*

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
          AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                          identityPoolId:@"YourIdentityPoolId"];
          AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                               credentialsProvider:credentialsProvider];
          [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

          return YES;
      }

 Then call the following to get the default service client:

 *Swift*

     let IoTDataManager = AWSIoTDataManager.default()

 *Objective-C*

     AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager defaultIoTDataManager];

 @return The default service client.
 */
+ (instancetype)defaultIoTDataManager __attribute__ ((deprecated("Use `registerIoTDataManagerWithConfiguration:forKey:` with the custom endpoint to initialize AWSIoTDataManager")));

/**
 Creates a service client with the given service configuration and registers it for the key.

 For example, set the default service configuration in `- application:didFinishLaunchingWithOptions:`

 *Swift*

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
         let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
         let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
         AWSIoTDataManager.register(with: configuration!, forKey: "USWest2IoTDataManager")

         return true
     }

 *Objective-C*

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                         identityPoolId:@"YourIdentityPoolId"];
         AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                              credentialsProvider:credentialsProvider];

         [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration forKey:@"USWest2IoTDataManager"];

         return YES;
     }

 Then call the following to get the service client:

 *Swift*

     let IoTDataManager = AWSIoTDataManager(forKey: "USWest2IoTDataManager")

 *Objective-C*

     AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@"USWest2IoTDataManager"];

 @warning After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

 @param configuration A service configuration object.
 @param key           A string to identify the service client.
 */
+ (void)registerIoTDataManagerWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key;



/**
 Creates a service client with the given service configuration and
 AWSIoTMQTTConfiguration and registers it for the key.

 For example:

 *Swift*

 let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
 let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
 let mqttConfig = AWSIoTMQTTConfiguration(keepAliveTimeInterval: 60.0,
                                      baseReconnectTimeInterval: 1.0,
                                  minimumConnectionTimeInterval: 20.0,
                                   maximumReconnectTimeInterval: 128.0,
                                                        runLoop: RunLoop.current,
                                                    runLoopMode: RunLoopMode.defaultRunLoopMode.rawValue,
                                                autoResubscribe: true,
                                           lastWillAndTestament: AWSIoTMQTTLastWillAndTestament() )

 AWSIoTDataManager.register(with: configuration!, with: mqttConfig!, forKey: "USWest2IoTDataManager")


 *Objective-C*

 AWSCognitoCredentialsProvider *credentialsProvider =
    [ [AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                identityPoolId:@"YourIdentityPoolId"];
 AWSServiceConfiguration *configuration =
    [ [AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                 credentialsProvider:credentialsProvider];
 AWSIoTMQTTConfiguration *mqttConfig =
    [ [AWSIoTMQTTConfiguration alloc] initWithKeepAliveTimeInterval:60.0
                                          baseReconnectTimeInterval:1.0
                                      minimumConnectionTimeInterval:20.0
                                       maximumReconnectTimeInterval:128.0
                                                            runLoop:[NSRunLoop currentRunLoop]
                                                        runLoopMode:NSDefaultRunLoopMode
                                                    autoResubscribe:YES
                                               lastWillAndTestament:[AWSIoTMQTTLastWillAndTestament new] ];

 [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration
                                      withMQTTConfiguration:mqttConfig
                                                     forKey:@"USWest2IoTDataManager"];

 Then call the following to get the service client:

 *Swift*

 let IoTDataManager = AWSIoTDataManager(forKey: "USWest2IoTDataManager")

 *Objective-C*

 AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@"USWest2IoTDataManager"];

 @warning After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

 @param configuration A service configuration object.
 @param mqttConfig    A AWSIoTMQTTConfiguration object.
 @param key           A string to identify the service client.
 */
+ (void)registerIoTDataManagerWithConfiguration:(AWSServiceConfiguration *)configuration
                          withMQTTConfiguration:(AWSIoTMQTTConfiguration *)mqttConfig
                                         forKey:(NSString *)key;


/**
 Retrieves the service client associated with the key. You need to call `+ registerIoTDataManagerWithConfiguration:forKey:` before invoking this method.

 For example, set the default service configuration in `- application:didFinishLaunchingWithOptions:`

 *Swift*

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
         let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
         let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
         AWSIoTDataManager.register(with: configuration!, forKey: "USWest2IoTDataManager")

         return true
     }

 *Objective-C*

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                         identityPoolId:@"YourIdentityPoolId"];
         AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                              credentialsProvider:credentialsProvider];

         [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration forKey:@"USWest2IoTDataManager"];

         return YES;
     }

 Then call the following to get the service client:

 *Swift*

     let IoTDataManager = AWSIoTDataManager(forKey: "USWest2IoTDataManager")

 *Objective-C*

     AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@"USWest2IoTDataManager"];

 @param key A string to identify the service client.

 @return An instance of the service client.
 */
+ (instancetype)IoTDataManagerForKey:(NSString *)key;

/**
 Removes the service client associated with the key and release it.

 @warning Before calling this method, make sure no method is running on this client.

 @param key A string to identify the service client.
 */
+ (void)removeIoTDataManagerForKey:(NSString *)key;

/**
 Enable or disable sending SDK name and version in the Mqtt Connect message. Enabled by default.
 Must be called before calling connect.
 */
- (void)enableMetricsCollection:(BOOL)enabled;

/**
 @deprecated This method is deprecated and will be deleted in the next minor version. Please use `updateUserMetaData` instead.
 Set user-specified dictionary of the additional values to be passed as components of
 connection username.
 *Swift*
 let userMetaData: [String: String] = ["AFRSDK": "ios", "AFRSDKVersion": "1.0.0", "AFRLibVersion":"1.4.1"]
 iotDataManager.addUserMetaData(userMetaData)
 @param userMetaData A dictionary of key-value metadata pairs to be appended to the connection username
 */
- (void)addUserMetaData:(NSDictionary<NSString *, NSString *> *)userMetaData
DEPRECATED_MSG_ATTRIBUTE("Use `updateUserMetaData` for updating the user meta data");

/**
 Set user-specified dictionary of the additional values to be passed as components of
 connection username.
 *Swift*
 let userMetaData: [String: String] = ["AFRSDK": "ios", "AFRSDKVersion": "1.0.0", "AFRLibVersion":"1.4.1"]
 iotDataManager.addUserMetaData(userMetaData)
 @param userMetaData A dictionary of key-value metadata pairs to be appended to the connection username
 */
- (void)updateUserMetaData:(NSDictionary<NSString *, NSString *> *)userMetaData;

/**
 Initialises the MQTT session and connects to AWS IoT using certificate-based mutual authentication

 @return true if initialise finished with success

 @param clientId The Client Identifier identifies the Client to the Server.

 @param cleanSession specifies if the server should discard previous session information.

 @param certificateId contains the ID of the certificate to use in the connection; must be in the keychain
 
 @param callback When new mqtt session status is received callback will be called with new connection status.

 */
- (BOOL)connectWithClientId:(NSString *)clientId
               cleanSession:(BOOL)cleanSession
              certificateId:(NSString *)certificateId
             statusCallback:(void (^)(AWSIoTMQTTStatus status))callback;

/**
 Initialises the MQTT session and connects to AWS IoT on port 443 using certificate-based mutual authentication
 and ALPN (Application Layer Protocol Negotiation)
 
 @return true if initialise finished with success
 
 @param clientId The Client Identifier identifies the Client to the Server.
 
 @param cleanSession specifies if the server should discard previous session information.
 
 @param certificateId contains the ID of the certificate to use in the connection; must be in the keychain
 
 @param callback When new mqtt session status is received callback will be called with new connection status.
 
 */
- (BOOL)connectUsingALPNWithClientId:(NSString *)clientId
               cleanSession:(BOOL)cleanSession
              certificateId:(NSString *)certificateId
             statusCallback:(void (^)(AWSIoTMQTTStatus status))callback
             API_AVAILABLE(ios(11), macosx(10.13));

/**
 Initialises the MQTT session and connects to AWS IoT using WebSocket/SigV4 authentication. IAM
 credentials are taken from the current service configuration.
 
 @return true if initialise finished with success
 
 @param clientId The Client Identifier identifies the Client to the Server.
 
 @param cleanSession specifies if the server should discard previous session information.
 
 @param callback When new mqtt session status is received the callback will be called with new connection status.
 
 */
- (BOOL)connectUsingWebSocketWithClientId:(NSString *)clientId
                            cleanSession:(BOOL)cleanSession
                          statusCallback:(void (^)(AWSIoTMQTTStatus status))callback;
    
/**
 Initialises the MQTT session and connects to AWS IoT using WebSocket/CustomAuthorizer mechanism.
 
 @param clientId The Client Identifier identifies the Client to the Server.
 
 @param cleanSession specifies if the server should discard previous session information.
 
 @param customAuthorizerName Name of the AWS IoT custom authorizer.
 
 @param tokenKeyName This specifies the key name that your device chooses, which indicates the token in the
 custom authorization HTTP request header.
 
 @param tokenValue This specifies the custom authorization token to authorize the request to the AWS IoT gateway.
 
 @param tokenSignature This specifies the token signature for the custom authorizer to validate the tokenValue.
 
 @param callback When new mqtt session status is received the callback will be called with new connection status.
 
 @return true if initialise finished with success.
 */
- (BOOL)connectUsingWebSocketWithClientId:(NSString *)clientId
                             cleanSession:(BOOL)cleanSession
                     customAuthorizerName:(NSString *)customAuthorizerName
                             tokenKeyName:(NSString *)tokenKeyName
                               tokenValue:(NSString *)tokenValue
                           tokenSignature:(NSString *)tokenSignature
                           statusCallback:(void (^)(AWSIoTMQTTStatus status))callback;

/**
 Disconnect from a mqtt client (close current mqtt session)

 */
- (void)disconnect;

/**
 Get the current connection status
 @return AWSIoTMQTTStatus
 */
- (AWSIoTMQTTStatus)getConnectionStatus;

/**
 Send MQTT message to specified topic

 @param string The message (As NSString object) to be sent.

 @param qos The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

 @param topic The topic for publish to.
 
 @return Boolean value indicating success or failure.

 */
- (BOOL) publishString:(NSString *)string
               onTopic:(NSString *)topic
                   QoS:(AWSIoTMQTTQoS)qos;

/**
 Send MQTT message to specified topic
 
 @param string The message (As NSString object) to be sent.
 
 @param qos The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).
 
 @param topic The topic for publish to.
 
 @param ackCallback the callback for ack if QoS > 0.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) publishString:(NSString *)string
               onTopic:(NSString *)topic
                   QoS:(AWSIoTMQTTQoS)qos
           ackCallback:(AWSIoTMQTTAckBlock)ackCallback;

/**
 Send MQTT message to specified topic

 @param data The message (As NSData) to be sent.

 @param qos The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

 @param topic The topic for publish to.

 @return Boolean value indicating success or failure.

 */
- (BOOL) publishData:(NSData *)data
             onTopic:(NSString *)topic
                 QoS:(AWSIoTMQTTQoS)qos;

/**
 Send MQTT message to specified topic
 
 @param data The message (As NSData) to be sent.
 
 @param qos The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).
 
 @param topic The topic for publish to.
 
 @param ackCallback the callback for ack if QoS > 0.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) publishData:(NSData *)data
             onTopic:(NSString *)topic
                 QoS:(AWSIoTMQTTQoS)qos
         ackCallback:(AWSIoTMQTTAckBlock)ackCallback;

/**
 Subscribes to a topic at a specific QoS level

 @param topic The Topic to subscribe to.

 @param qos Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce

 @param callback Reference to AWSIOTMQTTNewMessageBlock. When new message is received the callback will be invoked.
 
 @return Boolean value indicating success or failure.

 */
- (BOOL) subscribeToTopic:(NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
          messageCallback:(AWSIoTMQTTNewMessageBlock)callback;

/**
 Subscribes to a topic at a specific QoS level
 
 @param topic The Topic to subscribe to.
 
 @param qos Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce
 
 @param callback Reference to AWSIOTMQTTNewMessageBlock. When new message is received the callback will be invoked.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) subscribeToTopic:(NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
          messageCallback:(AWSIoTMQTTNewMessageBlock)callback
              ackCallback:(AWSIoTMQTTAckBlock)ackCallback;

/**
 Subscribes to a topic at a specific QoS level
 
 @param topic The Topic to subscribe to.
 
 @param qos Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce
 
 @param callback Reference to AWSIOTMQTTExtendedNewMessageBlock. When new message is received the callback will be invoked.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) subscribeToTopic:(NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
          extendedCallback:(AWSIoTMQTTExtendedNewMessageBlock)callback;

/**
 Subscribes to a topic at a specific QoS level
 
 @param topic The Topic to subscribe to.
 
 @param qos Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce
 
 @param callback Reference to AWSIOTMQTTExtendedNewMessageBlock. When new message is received the callback will be invoked.
 
 @param ackCallback the callback for ack if QoS > 0.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) subscribeToTopic:(NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
         extendedCallback:(AWSIoTMQTTExtendedNewMessageBlock)callback
              ackCallback:(AWSIoTMQTTAckBlock)ackCallback;


/**
 Unsubscribes from a topic

 @param topic The Topic to unsubscribe from.

 */
- (void)unsubscribeTopic:(NSString *)topic;


typedef NS_ENUM(NSInteger, AWSIoTShadowOperationType) {
    //
    // NOTE: the first 4 values in this enum may not be re-ordered.
    // It must align with the same order in AWSIoTShadowOperationTypeStrings
    // An internal array in the implementation depends on their
    // values and order.
    //
    AWSIoTShadowOperationTypeUpdate,
    AWSIoTShadowOperationTypeGet,
    AWSIoTShadowOperationTypeDelete,
    AWSIoTShadowOperationTypeCount,       // Internal class use only
    AWSIoTShadowOperationTypeNone         // Internal class use only
};

typedef NS_ENUM(NSInteger, AWSIoTShadowOperationStatusType) {
    //
    // NOTE: the first 5 values in this enum may not be re-ordered.
    // It must align with the same order in AWSIoTShadowOperationStatusTypeStrings
    // An internal array in the implementation depends on their
    // values and order.
    //
    AWSIoTShadowOperationStatusTypeAccepted,
    AWSIoTShadowOperationStatusTypeRejected,
    AWSIoTShadowOperationStatusTypeDelta,
    AWSIoTShadowOperationStatusTypeDocuments,
    AWSIoTShadowOperationStatusTypeCount, // Internal class use only
    AWSIoTShadowOperationStatusTypeForeignUpdate,
    AWSIoTShadowOperationStatusTypeTimeout
};

/**
 Register for updates on a device shadow
 
 @param name The device shadow to register for updates on.

 @param options A dictionary with device shadow registration options.  The options are:
 
enableDebugging: BOOL, set to YES to enable additional console debugging (default NO)
enableVersioning: BOOL, set to NO to disable versioning (default YES)
enableForeignStateUpdateNotifications: BOOL, set to YES to enable foreign state updates (default NO)
enableStaleDiscards: BOOL, set to NO to disable discarding stale updates (default YES)
enableIgnoreDeltas: BOOL, set to YES to disable delta updates (default NO)
QoS: AWSIoTMQTTQoS (default AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce)
shadowOperationTimeoutSeconds: double, device shadow operation timeout (default 10.0)
 
 @param callback The function to call when updates are received for the device shadow.
 
 @return Boolean value indicating success or failure.
 
 */

- (BOOL) registerWithShadow:(NSString *)name
                    options:(NSDictionary<NSString *, NSNumber *> * _Nullable)options
              eventCallback:(void(^)(NSString *name, AWSIoTShadowOperationType operation, AWSIoTShadowOperationStatusType status, NSString *clientToken, NSData *payload))callback;


/**
 Unregister from updates on a device shadow
 
 @param name The device shadow to unregister from updates on.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) unregisterFromShadow:(NSString *)name;

/**
 Update a device shadow
 
 @param name The device shadow to update.
 
 @param jsonString The JSON string to update the device shadow with.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) updateShadow:(NSString *)name
           jsonString:(NSString *)jsonString;

/**
 Update a device shadow with json data and client token.
 If the json data is not valid, it returns false, and no update message
 will be published. If the json data is valid, it publishes the data on
 $aws/things/thingName/shadow/update topic, then return true.

 @param name The name of the device shadow to be updated

 @param jsonString The shadow state in format of JSON string

 @param clientToken The client id to use when upadating the shadow

 @return True if json string is valid and can be serialized successfully;
 False if it cannot be serialized successfully.

 */

- (BOOL) updateShadow:(NSString *)name
           jsonString:(NSString *)jsonString
          clientToken:(NSString  * _Nullable)clientToken;

/**
 Get a device shadow
 
 @param name The device shadow to get.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) getShadow:(NSString *)name;

/**
 Get a device shadow
 
 @param name The device shadow to get.
 
 @param clientToken A client token to use when requesting the device shadow.
 
 @return Boolean value indicating success or failure.

 */
- (BOOL) getShadow:(NSString *)name
       clientToken:(NSString * _Nullable)clientToken;

/**
 Delete a device shadow
 
 @param name The device shadow to delete.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) deleteShadow:(NSString *)name;

/**
 Delete a device shadow
 
 @param name The device shadow to delete.
 
 @param clientToken A client token to use when deleting the device shadow.
 
 @return Boolean value indicating success or failure.
 
 */
- (BOOL) deleteShadow:(NSString *)name
          clientToken:(NSString * _Nullable)clientToken;


@end

Swift

class AWSIoTDataManager

Undocumented

  • The service configuration used to instantiate this service client.

    Warning

    Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration

    Swift

    var configuration: UnsafeMutablePointer<Int32> { get }
  • The MQTT configuration used by this service client. Any changes to this configuration object will take effect upon the next invocation of either the connectWithClientId or connectUsingWebSocketWithClientId methods.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) AWSIoTMQTTConfiguration *_Nonnull mqttConfiguration;

    Swift

    var mqttConfiguration: AWSIoTMQTTConfiguration { get }
  • Deprecated

    Use registerIoTDataManagerWithConfiguration:forKey: with the custom endpoint to initialize AWSIoTDataManager

    Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with defaultServiceConfiguration from [AWSServiceManager defaultServiceManager]. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

    For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

    Swift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
        let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
        AWSServiceManager.default().defaultServiceConfiguration = configuration
    
        return true
    }
    

    Objective-C

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                         identityPoolId:@"YourIdentityPoolId"];
         AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                              credentialsProvider:credentialsProvider];
         [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
    
         return YES;
     }
    

    Then call the following to get the default service client:

    Swift

    let IoTDataManager = AWSIoTDataManager.default()
    

    Objective-C

    AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager defaultIoTDataManager];
    

    Declaration

    Objective-C

    + (nonnull instancetype)defaultIoTDataManager;

    Swift

    class func `default`() -> Self

    Return Value

    The default service client.

  • Creates a service client with the given service configuration and registers it for the key.

    For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

    Swift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
        let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
        AWSIoTDataManager.register(with: configuration!, forKey: "USWest2IoTDataManager")
    
        return true
    }
    

    Objective-C

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                        identityPoolId:@"YourIdentityPoolId"];
        AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                             credentialsProvider:credentialsProvider];
    
        [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration forKey:@"USWest2IoTDataManager"];
    
        return YES;
    }
    

    Then call the following to get the service client:

    Swift

    let IoTDataManager = AWSIoTDataManager(forKey: "USWest2IoTDataManager")
    

    Objective-C

    AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@"USWest2IoTDataManager"];
    

    Warning

    After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

    Declaration

    Objective-C

    + (void)registerIoTDataManagerWithConfiguration:(id)configuration
                                             forKey:(nonnull NSString *)key;

    Swift

    class func register(withConfiguration configuration: Any!, forKey key: String)

    Parameters

    configuration

    A service configuration object.

    key

    A string to identify the service client.

  • Creates a service client with the given service configuration and AWSIoTMQTTConfiguration and registers it for the key.

    For example:

    Swift

    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: “YourIdentityPoolId”) let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider) let mqttConfig = AWSIoTMQTTConfiguration(keepAliveTimeInterval: 60.0, baseReconnectTimeInterval: 1.0, minimumConnectionTimeInterval: 20.0, maximumReconnectTimeInterval: 128.0, runLoop: RunLoop.current, runLoopMode: RunLoopMode.defaultRunLoopMode.rawValue, autoResubscribe: true, lastWillAndTestament: AWSIoTMQTTLastWillAndTestament() )

    AWSIoTDataManager.register(with: configuration!, with: mqttConfig!, forKey: “USWest2IoTDataManager”)

    Objective-C

    AWSCognitoCredentialsProvider *credentialsProvider = [ [AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@“YourIdentityPoolId”]; AWSServiceConfiguration *configuration = [ [AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider]; AWSIoTMQTTConfiguration *mqttConfig = [ [AWSIoTMQTTConfiguration alloc] initWithKeepAliveTimeInterval:60.0 baseReconnectTimeInterval:1.0 minimumConnectionTimeInterval:20.0 maximumReconnectTimeInterval:128.0 runLoop:[NSRunLoop currentRunLoop] runLoopMode:NSDefaultRunLoopMode autoResubscribe:YES lastWillAndTestament:[AWSIoTMQTTLastWillAndTestament new] ];

    [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration withMQTTConfiguration:mqttConfig forKey:@“USWest2IoTDataManager”];

    Then call the following to get the service client:

    Swift

    let IoTDataManager = AWSIoTDataManager(forKey: “USWest2IoTDataManager”)

    Objective-C

    AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@“USWest2IoTDataManager”];

    Warning

    After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

    Declaration

    Objective-C

    + (void)registerIoTDataManagerWithConfiguration:(id)configuration
                              withMQTTConfiguration:
                                  (nonnull AWSIoTMQTTConfiguration *)mqttConfig
                                             forKey:(nonnull NSString *)key;

    Swift

    class func register(withConfiguration configuration: Any!, with mqttConfig: AWSIoTMQTTConfiguration, forKey key: String)

    Parameters

    configuration

    A service configuration object.

    mqttConfig

    A AWSIoTMQTTConfiguration object.

    key

    A string to identify the service client.

  • Retrieves the service client associated with the key. You need to call + registerIoTDataManagerWithConfiguration:forKey: before invoking this method.

    For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

    Swift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
        let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
        AWSIoTDataManager.register(with: configuration!, forKey: "USWest2IoTDataManager")
    
        return true
    }
    

    Objective-C

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                        identityPoolId:@"YourIdentityPoolId"];
        AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                             credentialsProvider:credentialsProvider];
    
        [AWSIoTDataManager registerIoTDataManagerWithConfiguration:configuration forKey:@"USWest2IoTDataManager"];
    
        return YES;
    }
    

    Then call the following to get the service client:

    Swift

    let IoTDataManager = AWSIoTDataManager(forKey: "USWest2IoTDataManager")
    

    Objective-C

    AWSIoTDataManager *IoTDataManager = [AWSIoTDataManager IoTDataManagerForKey:@"USWest2IoTDataManager"];
    

    Declaration

    Objective-C

    + (nonnull instancetype)IoTDataManagerForKey:(nonnull NSString *)key;

    Swift

    convenience init(forKey key: String)

    Parameters

    key

    A string to identify the service client.

    Return Value

    An instance of the service client.

  • Removes the service client associated with the key and release it.

    Warning

    Before calling this method, make sure no method is running on this client.

    Declaration

    Objective-C

    + (void)removeIoTDataManagerForKey:(nonnull NSString *)key;

    Swift

    class func remove(forKey key: String)

    Parameters

    key

    A string to identify the service client.

  • Enable or disable sending SDK name and version in the Mqtt Connect message. Enabled by default. Must be called before calling connect.

    Declaration

    Objective-C

    - (void)enableMetricsCollection:(BOOL)enabled;

    Swift

    func enableMetricsCollection(_ enabled: Bool)
  • Deprecated

    Use updateUserMetaData for updating the user meta data

    @deprecated This method is deprecated and will be deleted in the next minor version. Please use updateUserMetaData instead. Set user-specified dictionary of the additional values to be passed as components of connection username. Swift let userMetaData: [String: String] = [“AFRSDK”: “ios”, “AFRSDKVersion”: “1.0.0”, “AFRLibVersion”:“1.4.1”] iotDataManager.addUserMetaData(userMetaData)

    Declaration

    Objective-C

    - (void)addUserMetaData:
        (nonnull NSDictionary<NSString *, NSString *> *)userMetaData;

    Swift

    func addUserMetaData(_ userMetaData: [String : String])

    Parameters

    userMetaData

    A dictionary of key-value metadata pairs to be appended to the connection username

  • Set user-specified dictionary of the additional values to be passed as components of connection username. Swift let userMetaData: [String: String] = [“AFRSDK”: “ios”, “AFRSDKVersion”: “1.0.0”, “AFRLibVersion”:“1.4.1”] iotDataManager.addUserMetaData(userMetaData)

    Declaration

    Objective-C

    - (void)updateUserMetaData:
        (nonnull NSDictionary<NSString *, NSString *> *)userMetaData;

    Swift

    func updateUserMetaData(_ userMetaData: [String : String])

    Parameters

    userMetaData

    A dictionary of key-value metadata pairs to be appended to the connection username

  • Initialises the MQTT session and connects to AWS IoT using certificate-based mutual authentication

    Declaration

    Objective-C

    - (BOOL)connectWithClientId:(nonnull NSString *)clientId
                   cleanSession:(BOOL)cleanSession
                  certificateId:(nonnull NSString *)certificateId
                 statusCallback:(nonnull void (^)(AWSIoTMQTTStatus))callback;

    Swift

    func connect(withClientId clientId: String, cleanSession: Bool, certificateId: String, statusCallback callback: @escaping (AWSIoTMQTTStatus) -> Void) -> Bool

    Parameters

    clientId

    The Client Identifier identifies the Client to the Server.

    cleanSession

    specifies if the server should discard previous session information.

    certificateId

    contains the ID of the certificate to use in the connection; must be in the keychain

    callback

    When new mqtt session status is received callback will be called with new connection status.

    Return Value

    true if initialise finished with success

  • Initialises the MQTT session and connects to AWS IoT on port 443 using certificate-based mutual authentication and ALPN (Application Layer Protocol Negotiation)

    Declaration

    Objective-C

    - (BOOL)connectUsingALPNWithClientId:(nonnull NSString *)clientId
                            cleanSession:(BOOL)cleanSession
                           certificateId:(nonnull NSString *)certificateId
                          statusCallback:
                              (nonnull void (^)(AWSIoTMQTTStatus))callback;

    Swift

    func connectUsingALPN(withClientId clientId: String, cleanSession: Bool, certificateId: String, statusCallback callback: @escaping (AWSIoTMQTTStatus) -> Void) -> Bool

    Parameters

    clientId

    The Client Identifier identifies the Client to the Server.

    cleanSession

    specifies if the server should discard previous session information.

    certificateId

    contains the ID of the certificate to use in the connection; must be in the keychain

    callback

    When new mqtt session status is received callback will be called with new connection status.

    Return Value

    true if initialise finished with success

  • Initialises the MQTT session and connects to AWS IoT using WebSocket/SigV4 authentication. IAM credentials are taken from the current service configuration.

    Declaration

    Objective-C

    - (BOOL)connectUsingWebSocketWithClientId:(nonnull NSString *)clientId
                                 cleanSession:(BOOL)cleanSession
                               statusCallback:
                                   (nonnull void (^)(AWSIoTMQTTStatus))callback;

    Swift

    func connectUsingWebSocket(withClientId clientId: String, cleanSession: Bool, statusCallback callback: @escaping (AWSIoTMQTTStatus) -> Void) -> Bool

    Parameters

    clientId

    The Client Identifier identifies the Client to the Server.

    cleanSession

    specifies if the server should discard previous session information.

    callback

    When new mqtt session status is received the callback will be called with new connection status.

    Return Value

    true if initialise finished with success

  • Initialises the MQTT session and connects to AWS IoT using WebSocket/CustomAuthorizer mechanism.

    Declaration

    Objective-C

    - (BOOL)connectUsingWebSocketWithClientId:(nonnull NSString *)clientId
                                 cleanSession:(BOOL)cleanSession
                         customAuthorizerName:
                             (nonnull NSString *)customAuthorizerName
                                 tokenKeyName:(nonnull NSString *)tokenKeyName
                                   tokenValue:(nonnull NSString *)tokenValue
                               tokenSignature:(nonnull NSString *)tokenSignature
                               statusCallback:
                                   (nonnull void (^)(AWSIoTMQTTStatus))callback;

    Swift

    func connectUsingWebSocket(withClientId clientId: String, cleanSession: Bool, customAuthorizerName: String, tokenKeyName: String, tokenValue: String, tokenSignature: String, statusCallback callback: @escaping (AWSIoTMQTTStatus) -> Void) -> Bool

    Parameters

    clientId

    The Client Identifier identifies the Client to the Server.

    cleanSession

    specifies if the server should discard previous session information.

    customAuthorizerName

    Name of the AWS IoT custom authorizer.

    tokenKeyName

    This specifies the key name that your device chooses, which indicates the token in the custom authorization HTTP request header.

    tokenValue

    This specifies the custom authorization token to authorize the request to the AWS IoT gateway.

    tokenSignature

    This specifies the token signature for the custom authorizer to validate the tokenValue.

    callback

    When new mqtt session status is received the callback will be called with new connection status.

    Return Value

    true if initialise finished with success.

  • Disconnect from a mqtt client (close current mqtt session)

    Declaration

    Objective-C

    - (void)disconnect;

    Swift

    func disconnect()
  • Get the current connection status

    Declaration

    Objective-C

    - (AWSIoTMQTTStatus)getConnectionStatus;

    Swift

    func getConnectionStatus() -> AWSIoTMQTTStatus

    Return Value

    AWSIoTMQTTStatus

  • Send MQTT message to specified topic

    Declaration

    Objective-C

    - (BOOL)publishString:(nonnull NSString *)string
                  onTopic:(nonnull NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos;

    Swift

    func publishString(_ string: String, onTopic topic: String, qoS qos: AWSIoTMQTTQoS) -> Bool

    Parameters

    string

    The message (As NSString object) to be sent.

    qos

    The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

    topic

    The topic for publish to.

    Return Value

    Boolean value indicating success or failure.

  • Send MQTT message to specified topic

    Declaration

    Objective-C

    - (BOOL)publishString:(nonnull NSString *)string
                  onTopic:(nonnull NSString *)topic
                      QoS:(AWSIoTMQTTQoS)qos
              ackCallback:(nonnull AWSIoTMQTTAckBlock)ackCallback;

    Swift

    func publishString(_ string: String, onTopic topic: String, qoS qos: AWSIoTMQTTQoS, ackCallback: @escaping AWSIoTMQTTAckBlock) -> Bool

    Parameters

    string

    The message (As NSString object) to be sent.

    qos

    The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

    topic

    The topic for publish to.

    ackCallback

    the callback for ack if QoS > 0.

    Return Value

    Boolean value indicating success or failure.

  • Send MQTT message to specified topic

    Declaration

    Objective-C

    - (BOOL)publishData:(nonnull NSData *)data
                onTopic:(nonnull NSString *)topic
                    QoS:(AWSIoTMQTTQoS)qos;

    Swift

    func publishData(_ data: Data, onTopic topic: String, qoS qos: AWSIoTMQTTQoS) -> Bool

    Parameters

    data

    The message (As NSData) to be sent.

    qos

    The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

    topic

    The topic for publish to.

    Return Value

    Boolean value indicating success or failure.

  • Send MQTT message to specified topic

    Declaration

    Objective-C

    - (BOOL)publishData:(nonnull NSData *)data
                onTopic:(nonnull NSString *)topic
                    QoS:(AWSIoTMQTTQoS)qos
            ackCallback:(nonnull AWSIoTMQTTAckBlock)ackCallback;

    Swift

    func publishData(_ data: Data, onTopic topic: String, qoS qos: AWSIoTMQTTQoS, ackCallback: @escaping AWSIoTMQTTAckBlock) -> Bool

    Parameters

    data

    The message (As NSData) to be sent.

    qos

    The QoS value to use when publishing (optional, default AWSIoTMQTTQoSAtMostOnce).

    topic

    The topic for publish to.

    ackCallback

    the callback for ack if QoS > 0.

    Return Value

    Boolean value indicating success or failure.

  • Subscribes to a topic at a specific QoS level

    Declaration

    Objective-C

    - (BOOL)subscribeToTopic:(nonnull NSString *)topic
                         QoS:(AWSIoTMQTTQoS)qos
             messageCallback:(nonnull AWSIoTMQTTNewMessageBlock)callback;

    Swift

    func subscribe(toTopic topic: String, qoS qos: AWSIoTMQTTQoS, messageCallback callback: @escaping AWSIoTMQTTNewMessageBlock) -> Bool

    Parameters

    topic

    The Topic to subscribe to.

    qos

    Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce

    callback

    Reference to AWSIOTMQTTNewMessageBlock. When new message is received the callback will be invoked.

    Return Value

    Boolean value indicating success or failure.

  • Subscribes to a topic at a specific QoS level

    Declaration

    Objective-C

    - (BOOL)subscribeToTopic:(nonnull NSString *)topic
                         QoS:(AWSIoTMQTTQoS)qos
             messageCallback:(nonnull AWSIoTMQTTNewMessageBlock)callback
                 ackCallback:(nonnull AWSIoTMQTTAckBlock)ackCallback;

    Swift

    func subscribe(toTopic topic: String, qoS qos: AWSIoTMQTTQoS, messageCallback callback: @escaping AWSIoTMQTTNewMessageBlock, ackCallback: @escaping AWSIoTMQTTAckBlock) -> Bool

    Parameters

    topic

    The Topic to subscribe to.

    qos

    Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce

    callback

    Reference to AWSIOTMQTTNewMessageBlock. When new message is received the callback will be invoked.

    Return Value

    Boolean value indicating success or failure.

  • Subscribes to a topic at a specific QoS level

    Declaration

    Objective-C

    - (BOOL)subscribeToTopic:(nonnull NSString *)topic
                         QoS:(AWSIoTMQTTQoS)qos
            extendedCallback:(nonnull AWSIoTMQTTExtendedNewMessageBlock)callback;

    Swift

    func subscribe(toTopic topic: String, qoS qos: AWSIoTMQTTQoS, extendedCallback callback: @escaping AWSIoTMQTTExtendedNewMessageBlock) -> Bool

    Parameters

    topic

    The Topic to subscribe to.

    qos

    Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce

    callback

    Reference to AWSIOTMQTTExtendedNewMessageBlock. When new message is received the callback will be invoked.

    Return Value

    Boolean value indicating success or failure.

  • Subscribes to a topic at a specific QoS level

    Declaration

    Objective-C

    - (BOOL)subscribeToTopic:(nonnull NSString *)topic
                         QoS:(AWSIoTMQTTQoS)qos
            extendedCallback:(nonnull AWSIoTMQTTExtendedNewMessageBlock)callback
                 ackCallback:(nonnull AWSIoTMQTTAckBlock)ackCallback;

    Swift

    func subscribe(toTopic topic: String, qoS qos: AWSIoTMQTTQoS, extendedCallback callback: @escaping AWSIoTMQTTExtendedNewMessageBlock, ackCallback: @escaping AWSIoTMQTTAckBlock) -> Bool

    Parameters

    topic

    The Topic to subscribe to.

    qos

    Specifies the QoS Level of the subscription: AWSIoTMQTTQoSAtMostOnce or AWSIoTMQTTQoSAtLeastOnce

    callback

    Reference to AWSIOTMQTTExtendedNewMessageBlock. When new message is received the callback will be invoked.

    ackCallback

    the callback for ack if QoS > 0.

    Return Value

    Boolean value indicating success or failure.

  • Unsubscribes from a topic

    Declaration

    Objective-C

    - (void)unsubscribeTopic:(nonnull NSString *)topic;

    Swift

    func unsubscribeTopic(_ topic: String)

    Parameters

    topic

    The Topic to unsubscribe from.

  • Register for updates on a device shadow

    enableDebugging: BOOL, set to YES to enable additional console debugging (default NO) enableVersioning: BOOL, set to NO to disable versioning (default YES) enableForeignStateUpdateNotifications: BOOL, set to YES to enable foreign state updates (default NO) enableStaleDiscards: BOOL, set to NO to disable discarding stale updates (default YES) enableIgnoreDeltas: BOOL, set to YES to disable delta updates (default NO) QoS: AWSIoTMQTTQoS (default AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce) shadowOperationTimeoutSeconds: double, device shadow operation timeout (default 10.0)

    Declaration

    Objective-C

    - (BOOL)
        registerWithShadow:(nonnull NSString *)name
                   options:(NSDictionary<NSString *, NSNumber *> *_Nullable)options
             eventCallback:
                 (nonnull void (^)(NSString *_Nonnull, AWSIoTShadowOperationType,
                                   AWSIoTShadowOperationStatusType,
                                   NSString *_Nonnull, NSData *_Nonnull))callback;

    Swift

    func register(withShadow name: String, options: [String : NSNumber]? = nil, eventCallback callback: @escaping (String, AWSIoTShadowOperationType, AWSIoTShadowOperationStatusType, String, Data) -> Void) -> Bool

    Parameters

    name

    The device shadow to register for updates on.

    options

    A dictionary with device shadow registration options. The options are:

    callback

    The function to call when updates are received for the device shadow.

    Return Value

    Boolean value indicating success or failure.

  • Unregister from updates on a device shadow

    Declaration

    Objective-C

    - (BOOL)unregisterFromShadow:(nonnull NSString *)name;

    Swift

    func unregister(fromShadow name: String) -> Bool

    Parameters

    name

    The device shadow to unregister from updates on.

    Return Value

    Boolean value indicating success or failure.

  • Update a device shadow

    Declaration

    Objective-C

    - (BOOL)updateShadow:(nonnull NSString *)name
              jsonString:(nonnull NSString *)jsonString;

    Swift

    func updateShadow(_ name: String, jsonString: String) -> Bool

    Parameters

    name

    The device shadow to update.

    jsonString

    The JSON string to update the device shadow with.

    Return Value

    Boolean value indicating success or failure.

  • Update a device shadow with json data and client token. If the json data is not valid, it returns false, and no update message will be published. If the json data is valid, it publishes the data on $aws/things/thingName/shadow/update topic, then return true.

    Declaration

    Objective-C

    - (BOOL)updateShadow:(nonnull NSString *)name
              jsonString:(nonnull NSString *)jsonString
             clientToken:(NSString *_Nullable)clientToken;

    Swift

    func updateShadow(_ name: String, jsonString: String, clientToken: String?) -> Bool

    Parameters

    name

    The name of the device shadow to be updated

    jsonString

    The shadow state in format of JSON string

    clientToken

    The client id to use when upadating the shadow

    Return Value

    True if json string is valid and can be serialized successfully; False if it cannot be serialized successfully.

  • Get a device shadow

    Declaration

    Objective-C

    - (BOOL)getShadow:(nonnull NSString *)name;

    Swift

    func getShadow(_ name: String) -> Bool

    Parameters

    name

    The device shadow to get.

    Return Value

    Boolean value indicating success or failure.

  • Get a device shadow

    Declaration

    Objective-C

    - (BOOL)getShadow:(nonnull NSString *)name
          clientToken:(NSString *_Nullable)clientToken;

    Swift

    func getShadow(_ name: String, clientToken: String?) -> Bool

    Parameters

    name

    The device shadow to get.

    clientToken

    A client token to use when requesting the device shadow.

    Return Value

    Boolean value indicating success or failure.

  • Delete a device shadow

    Declaration

    Objective-C

    - (BOOL)deleteShadow:(nonnull NSString *)name;

    Swift

    func deleteShadow(_ name: String) -> Bool

    Parameters

    name

    The device shadow to delete.

    Return Value

    Boolean value indicating success or failure.

  • Delete a device shadow

    Declaration

    Objective-C

    - (BOOL)deleteShadow:(nonnull NSString *)name
             clientToken:(NSString *_Nullable)clientToken;

    Swift

    func deleteShadow(_ name: String, clientToken: String?) -> Bool

    Parameters

    name

    The device shadow to delete.

    clientToken

    A client token to use when deleting the device shadow.

    Return Value

    Boolean value indicating success or failure.