AWSIoTData
Objective-C
@interface AWSIoTData
Swift
class AWSIoTData
AWS IoT-Data enables secure, bi-directional communication between Internet-connected things (such as sensors, actuators, embedded devices, or smart appliances) and the AWS cloud. It implements a broker for applications and things to publish messages over HTTP (Publish) and retrieve, update, and delete shadows. A shadow is a persistent representation of your things and their state in the AWS cloud.
Find the endpoint address for actions in the AWS IoT data plane by running this CLI command:
aws iot describe-endpoint --endpoint-type iot:Data-ATS
The service name used by AWS Signature Version 4 to sign requests is: iotdevicegateway.
-
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 }
-
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 IoTData = AWSIoTData.default()
Objective-C
AWSIoTData *IoTData = [AWSIoTData defaultIoTData];
Declaration
Objective-C
+ (nonnull instancetype)defaultIoTData;
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) AWSIoTData.register(with: configuration!, forKey: "USWest2IoTData") 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]; [AWSIoTData registerIoTDataWithConfiguration:configuration forKey:@"USWest2IoTData"]; return YES; }
Then call the following to get the service client:
Swift
let IoTData = AWSIoTData(forKey: "USWest2IoTData")
Objective-C
AWSIoTData *IoTData = [AWSIoTData IoTDataForKey:@"USWest2IoTData"];
Warning
After calling this method, do not modify the configuration object. It may cause unspecified behaviors.
Declaration
Objective-C
+ (void)registerIoTDataWithConfiguration:(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.
-
Retrieves the service client associated with the key. You need to call
+ registerIoTDataWithConfiguration: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) AWSIoTData.register(with: configuration!, forKey: "USWest2IoTData") 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]; [AWSIoTData registerIoTDataWithConfiguration:configuration forKey:@"USWest2IoTData"]; return YES; }
Then call the following to get the service client:
Swift
let IoTData = AWSIoTData(forKey: "USWest2IoTData")
Objective-C
AWSIoTData *IoTData = [AWSIoTData IoTDataForKey:@"USWest2IoTData"];
Declaration
Objective-C
+ (nonnull instancetype)IoTDataForKey:(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)removeIoTDataForKey:(nonnull NSString *)key;
Swift
class func remove(forKey key: String)
Parameters
key
A string to identify the service client.
-
Deletes the shadow for the specified thing.
For more information, see DeleteThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataDeleteThingShadowRequest
See
AWSIoTDataDeleteThingShadowResponse
Declaration
Objective-C
- (id)deleteThingShadow:(nonnull AWSIoTDataDeleteThingShadowRequest *)request;
Swift
func deleteThingShadow(_ request: AWSIoTDataDeleteThingShadowRequest) -> Any!
Parameters
request
A container for the necessary parameters to execute the DeleteThingShadow service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSIoTDataDeleteThingShadowResponse
. On failed execution,task.error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
. -
Deletes the shadow for the specified thing.
For more information, see DeleteThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataDeleteThingShadowRequest
See
AWSIoTDataDeleteThingShadowResponse
Declaration
Objective-C
- (void)deleteThingShadow:(nonnull AWSIoTDataDeleteThingShadowRequest *)request completionHandler: (void (^_Nullable)(AWSIoTDataDeleteThingShadowResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func deleteThingShadow(_ request: AWSIoTDataDeleteThingShadowRequest, completionHandler: ((AWSIoTDataDeleteThingShadowResponse?, Error?) -> Void)? = nil)
Parameters
request
A container for the necessary parameters to execute the DeleteThingShadow service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
. -
Gets the shadow for the specified thing.
For more information, see GetThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataGetThingShadowRequest
See
AWSIoTDataGetThingShadowResponse
Declaration
Objective-C
- (id)getThingShadow:(nonnull AWSIoTDataGetThingShadowRequest *)request;
Swift
func getThingShadow(_ request: AWSIoTDataGetThingShadowRequest) -> Any!
Parameters
request
A container for the necessary parameters to execute the GetThingShadow service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSIoTDataGetThingShadowResponse
. On failed execution,task.error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
. -
Gets the shadow for the specified thing.
For more information, see GetThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataGetThingShadowRequest
See
AWSIoTDataGetThingShadowResponse
Declaration
Objective-C
- (void)getThingShadow:(nonnull AWSIoTDataGetThingShadowRequest *)request completionHandler: (void (^_Nullable)(AWSIoTDataGetThingShadowResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func getThingShadow(_ request: AWSIoTDataGetThingShadowRequest, completionHandler: ((AWSIoTDataGetThingShadowResponse?, Error?) -> Void)? = nil)
Parameters
request
A container for the necessary parameters to execute the GetThingShadow service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
. -
Lists the shadows for the specified thing.
See
AWSIoTDataListNamedShadowsForThingRequest
See
AWSIoTDataListNamedShadowsForThingResponse
Declaration
Objective-C
- (id)listNamedShadowsForThing: (nonnull AWSIoTDataListNamedShadowsForThingRequest *)request;
Swift
func listNamedShadows(forThing request: AWSIoTDataListNamedShadowsForThingRequest) -> Any!
Parameters
request
A container for the necessary parameters to execute the ListNamedShadowsForThing service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSIoTDataListNamedShadowsForThingResponse
. On failed execution,task.error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
. -
Lists the shadows for the specified thing.
See
AWSIoTDataListNamedShadowsForThingRequest
See
AWSIoTDataListNamedShadowsForThingResponse
Declaration
Objective-C
- (void)listNamedShadowsForThing: (nonnull AWSIoTDataListNamedShadowsForThingRequest *)request completionHandler: (void (^_Nullable)( AWSIoTDataListNamedShadowsForThingResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func listNamedShadows(forThing request: AWSIoTDataListNamedShadowsForThingRequest, completionHandler: ((AWSIoTDataListNamedShadowsForThingResponse?, Error?) -> Void)? = nil)
Parameters
request
A container for the necessary parameters to execute the ListNamedShadowsForThing service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorResourceNotFound
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
. -
Publishes state information.
For more information, see HTTP Protocol in the AWS IoT Developer Guide.
See
AWSIoTDataPublishRequest
Declaration
Objective-C
- (id)publish:(nonnull AWSIoTDataPublishRequest *)request;
Swift
func publish(_ request: AWSIoTDataPublishRequest) -> Any!
Parameters
request
A container for the necessary parameters to execute the Publish service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will benil
. On failed execution,task.error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorMethodNotAllowed
. -
Publishes state information.
For more information, see HTTP Protocol in the AWS IoT Developer Guide.
See
AWSIoTDataPublishRequest
Declaration
Objective-C
- (void)publish:(nonnull AWSIoTDataPublishRequest *)request completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func publish(_ request: AWSIoTDataPublishRequest, completionHandler: ((Error?) -> Void)? = nil)
Parameters
request
A container for the necessary parameters to execute the Publish service method.
completionHandler
The completion handler to call when the load request is complete.
error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorMethodNotAllowed
. -
Updates the shadow for the specified thing.
For more information, see UpdateThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataUpdateThingShadowRequest
See
AWSIoTDataUpdateThingShadowResponse
Declaration
Objective-C
- (id)updateThingShadow:(nonnull AWSIoTDataUpdateThingShadowRequest *)request;
Swift
func updateThingShadow(_ request: AWSIoTDataUpdateThingShadowRequest) -> Any!
Parameters
request
A container for the necessary parameters to execute the UpdateThingShadow service method.
Return Value
An instance of
AWSTask
. On successful execution,task.result
will contain an instance ofAWSIoTDataUpdateThingShadowResponse
. On failed execution,task.error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorConflict
,AWSIoTDataErrorRequestEntityTooLarge
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
. -
Updates the shadow for the specified thing.
For more information, see UpdateThingShadow in the AWS IoT Developer Guide.
See
AWSIoTDataUpdateThingShadowRequest
See
AWSIoTDataUpdateThingShadowResponse
Declaration
Objective-C
- (void)updateThingShadow:(nonnull AWSIoTDataUpdateThingShadowRequest *)request completionHandler: (void (^_Nullable)(AWSIoTDataUpdateThingShadowResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func updateThingShadow(_ request: AWSIoTDataUpdateThingShadowRequest, completionHandler: ((AWSIoTDataUpdateThingShadowResponse?, Error?) -> Void)? = nil)
Parameters
request
A container for the necessary parameters to execute the UpdateThingShadow service method.
completionHandler
The completion handler to call when the load request is complete.
response
- A response object, ornil
if the request failed.error
- An error object that indicates why the request failed, ornil
if the request was successful. On failed execution,error
may contain anNSError
withAWSIoTDataErrorDomain
domain and the following error code:AWSIoTDataErrorConflict
,AWSIoTDataErrorRequestEntityTooLarge
,AWSIoTDataErrorInvalidRequest
,AWSIoTDataErrorThrottling
,AWSIoTDataErrorUnauthorized
,AWSIoTDataErrorServiceUnavailable
,AWSIoTDataErrorInternalFailure
,AWSIoTDataErrorMethodNotAllowed
,AWSIoTDataErrorUnsupportedDocumentEncoding
.