This sample demonstrates use of the AWS IoT MQTT device shadow APIs over a WebSocket. It works in conjunction with the Temperature Control Example Program in the AWS IoT JavaScript SDK for Embedded Devices.
- Xcode 7 and later
- iOS 8 and later
-
The AWS Mobile SDK for iOS is available through CocoaPods. If you have not installed CocoaPods, install CocoaPods:
sudo gem install cocoapods pod setup
-
To install the AWS Mobile SDK for iOS, simply add the following line to your Podfile:
pod 'AWSIoT'
Then run the following command:
pod install
-
In the Amazon IAM console, use Amazon IAM to create a new user. Obtain the
Access Key ID
andSecret Access Key
constants. Make sure the policy attached to the user has full permissions to access the AWS IoT APIs, as shown in this example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:*"
],
"Resource": "*"
}
]
}
-
Open
IoTTemperatureControlSample.xcworkspace
. -
Open
Constants.swift
and update the following lines with the appropriate constants:
let AwsRegion = AWSRegionType.Unknown // e.g. AWSRegionType.USEast1
let IamAccessKeyId = "YourIAMAccessKeyId"
let IamSecretAccessKey = "YourIAMSecretAccessKey"
Note that the use of hard-coded IAM user credentials is not recommended for production applications.
-
Install the AWS IoT JavaScript SDK for Embedded Devices.
-
Follow the instructions in the AWS IoT JavaScript SDK for Embedded Devices to install depenedencies for the temperature-control example application.
-
Start the AWS IoT JavaScript SDK for Embedded Devices temperature-control example application using '--test-mode=2' to simulate a temperature control device.
-
Build and run the sample app.