AWSIoTManager
Objective-C
@interface AWSIoTManager : 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;
/**
Enables the custom tag which will include the certificateId when adding a certificate.
Default: False
*/
@property (nonatomic, class, assign) BOOL tagCertificateEnabled;
/**
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 IoTManager = AWSIoTManager.default()
*Objective-C*
AWSIoTManager *IoTManager = [AWSIoTManager defaultIoTManager];
@return The default service client.
*/
+ (instancetype)defaultIoTManager;
/**
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)
AWSIoTManager.register(with: configuration!, forKey: "USWest2IoTManager")
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];
[AWSIoTManager registerIoTManagerWithConfiguration:configuration forKey:@"USWest2IoTManager"];
return YES;
}
Then call the following to get the service client:
*Swift*
let IoTManager = AWSIoTManager(forKey: "USWest2IoTManager")
*Objective-C*
AWSIoTManager *IoTManager = [AWSIoTManager IoTManagerForKey:@"USWest2IoTManager"];
@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)registerIoTManagerWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key;
/**
Retrieves the service client associated with the key. You need to call `+ registerIoTManagerWithConfiguration: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)
AWSIoTManager.register(with: configuration!, forKey: "USWest2IoTManager")
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];
[AWSIoTManager registerIoTManagerWithConfiguration:configuration forKey:@"USWest2IoTManager"];
return YES;
}
Then call the following to get the service client:
*Swift*
let IoTManager = AWSIoTManager(forKey: "USWest2IoTManager")
*Objective-C*
AWSIoTManager *IoTManager = [AWSIoTManager IoTManagerForKey:@"USWest2IoTManager"];
@param key A string to identify the service client.
@return An instance of the service client.
*/
+ (instancetype)IoTManagerForKey:(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)removeIoTManagerForKey:(NSString *)key;
/**
* Creates keys and certificate from a CSR created using the specified dictionary
*
* @param csrDictionary contains values used to generate the CSR. Requires values for
* keys: commonName, countryName, organizationName, organizationalUnitName
*
* @param callback When new certificate is created the function of block will be called with an instance of `AWSIOTDescribeCertificateResponse`
*/
- (void)createKeysAndCertificateFromCsr:(NSDictionary<NSString *, NSString*> *)csrDictionary callback:(void (^)(AWSIoTCreateCertificateResponse *mainResponse))callback;
/**
* Import PKCS12 identity into keychain. This method allows you to import an
* identity created using the AWS console or CLI into the keychain. The identity is
* contained in PKCS12 data; you can create PKCS12 files (suffix .p12) using openssl
* as follows:
*
* openssl pkcs12 -export -in cert.pem -inkey key.pem -CAfile root-ca.crt -out awsiot-identity.p12
*
* @param pkcs12Data pkcs12 raw data. Will only import the first item.
*
* @param passPhrase Pass phrase used to decrypt the pkcs12 data.
*
* @param certificateId Unique identifier used to find the key/certificate for use.
*
*/
+ (BOOL)importIdentityFromPKCS12Data:(NSData *)pkcs12Data passPhrase:(NSString *)passPhrase certificateId:(NSString *)certificateId;
/**
* Validates the certificate with the given identifier of certificate.
*
* @param certificateId The certificate identifier
*
* @return TRUE if certificate is valid, else FALSE
*/
+ (BOOL)isValidCertificate:(NSString *)certificateId;
/**
* Deletes keys and certificate
*
* @return TRUE if certificate is deleted, else FALSE
*/
+ (BOOL)deleteCertificate;
+ (BOOL)deleteCertificateWithCertificateId:(NSString*)certificateId NS_SWIFT_NAME(deleteCertificate(certificateId:));
+ (void)setKeyChainAccessibility:(AWSIoTKeyChainAccessibility)accessibility;
+ (NSString *)certTagWithCertificateId:(NSString *)certificateId;
@end
Swift
class AWSIoTManager
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
-
Enables the custom tag which will include the certificateId when adding a certificate.
Default: False
Declaration
Objective-C
@property (class, nonatomic) BOOL tagCertificateEnabled;
Swift
class var tagCertificateEnabled: Bool { get set }
-
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 IoTManager = AWSIoTManager.default()
Objective-C
AWSIoTManager *IoTManager = [AWSIoTManager defaultIoTManager];
Declaration
Objective-C
+ (instancetype)defaultIoTManager;
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) AWSIoTManager.register(with: configuration!, forKey: "USWest2IoTManager") 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]; [AWSIoTManager registerIoTManagerWithConfiguration:configuration forKey:@"USWest2IoTManager"]; return YES; }
Then call the following to get the service client:
Swift
let IoTManager = AWSIoTManager(forKey: "USWest2IoTManager")
Objective-C
AWSIoTManager *IoTManager = [AWSIoTManager IoTManagerForKey:@"USWest2IoTManager"];
Warning
After calling this method, do not modify the configuration object. It may cause unspecified behaviors.
Declaration
Objective-C
+ (void)registerIoTManagerWithConfiguration:(id)configuration forKey:(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
+ registerIoTManagerWithConfiguration: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) AWSIoTManager.register(with: configuration!, forKey: "USWest2IoTManager") 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]; [AWSIoTManager registerIoTManagerWithConfiguration:configuration forKey:@"USWest2IoTManager"]; return YES; }
Then call the following to get the service client:
Swift
let IoTManager = AWSIoTManager(forKey: "USWest2IoTManager")
Objective-C
AWSIoTManager *IoTManager = [AWSIoTManager IoTManagerForKey:@"USWest2IoTManager"];
Declaration
Objective-C
+ (instancetype)IoTManagerForKey:(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)removeIoTManagerForKey:(NSString *)key;
Swift
class func remove(forKey key: String!)
Parameters
key
A string to identify the service client.
-
Creates keys and certificate from a CSR created using the specified dictionary
Declaration
Objective-C
- (void)createKeysAndCertificateFromCsr: (NSDictionary<NSString *, NSString *> *)csrDictionary callback: (void (^)(AWSIoTCreateCertificateResponse *)) callback;
Swift
func createKeysAndCertificate(fromCsr csrDictionary: [String : String]!, callback: ((AWSIoTCreateCertificateResponse?) -> Void)!)
Parameters
csrDictionary
contains values used to generate the CSR. Requires values for keys: commonName, countryName, organizationName, organizationalUnitName
callback
When new certificate is created the function of block will be called with an instance of
AWSIOTDescribeCertificateResponse
-
Import PKCS12 identity into keychain. This method allows you to import an identity created using the AWS console or CLI into the keychain. The identity is contained in PKCS12 data; you can create PKCS12 files (suffix .p12) using openssl as follows:
openssl pkcs12 -export -in cert.pem -inkey key.pem -CAfile root-ca.crt -out awsiot-identity.p12
Declaration
Objective-C
+ (BOOL)importIdentityFromPKCS12Data:(NSData *)pkcs12Data passPhrase:(NSString *)passPhrase certificateId:(NSString *)certificateId;
Swift
class func importIdentity(fromPKCS12Data pkcs12Data: Data!, passPhrase: String!, certificateId: String!) -> Bool
Parameters
pkcs12Data
pkcs12 raw data. Will only import the first item.
passPhrase
Pass phrase used to decrypt the pkcs12 data.
certificateId
Unique identifier used to find the key/certificate for use.
-
Validates the certificate with the given identifier of certificate.
Declaration
Objective-C
+ (BOOL)isValidCertificate:(NSString *)certificateId;
Swift
class func isValidCertificate(_ certificateId: String!) -> Bool
Parameters
certificateId
The certificate identifier
Return Value
TRUE if certificate is valid, else FALSE
-
Deletes keys and certificate
Declaration
Objective-C
+ (BOOL)deleteCertificate;
Swift
class func deleteCertificate() -> Bool
Return Value
TRUE if certificate is deleted, else FALSE
-
Undocumented
Declaration
Objective-C
+ (BOOL)deleteCertificateWithCertificateId:(NSString*)certificateId NS_SWIFT_NAME(deleteCertificate(certificateId:));
Swift
class func deleteCertificate(certificateId: String!) -> Bool
-
Undocumented
Declaration
Objective-C
+ (void)setKeyChainAccessibility:(AWSIoTKeyChainAccessibility)accessibility;
Swift
class func setKeyChainAccessibility(_ accessibility: AWSIoTKeyChainAccessibility)
-
Undocumented
Declaration
Objective-C
+ (NSString *)certTagWithCertificateId:(NSString *)certificateId;
Swift
class func certTag(withCertificateId certificateId: String!) -> String!