AWSCloudLogic Class Reference

Inherits from NSObject
Declared in AWSCloudLogic.h
AWSCloudLogic.m

Overview

Cloud logic helper singleton class that provides convenient interface to invoke AWS Lambda functions and handle the results asynchronously. Requires the AWSLambda framework of AWSiOSSDK.

+ defaultCloudLogic

Returns the default Cloud Logic singleton instance configured using the information provided in Info.plist file.

+ (instancetype)defaultCloudLogic

Discussion

Swift

let cloudLogic = AWSCloudLogic.defaultCloudLogic()

Objective-C

AWSCloudLogic *cloudLogic =  [AWSCloudLogic defaultCloudLogic];

Declared In

AWSCloudLogic.h

+ registerCloudLogicWithConfiguration:forKey:

Creates a helper client for AWSCloud for specified configuration with mentioned key. Use this method only if you require a helper client with specific configuration.

+ (void)registerCloudLogicWithConfiguration:(AWSServiceConfiguration *)serviceConfiguration forKey:(NSString *)key

Parameters

serviceConfiguration

AWSServiceConfiguration object for the cloud logic.

key

A string to identify the helper client.

Discussion

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

Swift

let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)

AWSCloudLogic.registercloudLogicWithConfiguration(configuration, forKey: "USWest2cloudLogic")

Objective-C

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                     credentialsProvider:credentialsProvider];
[AWSCloudLogic registercloudLogicWithConfiguration:configuration
                                            forKey:@"USWest2cloudLogic"];

Then call the following to get the helper client:

Swift

let cloudLogic = AWSCloudLogic(forKey: "USWest2cloudLogic")

Objective-C

AWSCloudLogic *cloudLogic = [AWSCloudLogic cloudLogicForKey:@"USWest2cloudLogic"];

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

Declared In

AWSCloudLogic.h

+ CloudLogicForKey:NS_SWIFT_NAME:

Retrieves the helper client associated with the key. You need to call + registercloudLogicWithConfiguration: before invoking this method. If + registercloudLogicWithConfiguration: has not been called in advance or the key does not exist, this method returns nil.

+ (instancetype)CloudLogicForKey:(NSString *)key NS_SWIFT_NAME

Parameters

key

A string to identify the helper client.

Return Value

An instance of AWSCloudLogic for specified key.

Discussion

Swift

let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)

AWSCloudLogic.registercloudLogicWithConfiguration(configuration, forKey: "USWest2cloudLogic")

Objective-C

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                     credentialsProvider:credentialsProvider];
[AWSCloudLogic registercloudLogicWithConfiguration:configuration
                                            forKey:@"USWest2cloudLogic"];

Then call the following to get the helper client:

Swift

let CloudLogic = AWSCloudLogic.CloudLogic(forKey: "USWest2cloudLogic")

Objective-C

AWSCloudLogic *CloudLogic = [AWSCloudLogic CloudLogicForKey:@"USWest2cloudLogic"];

Declared In

AWSCloudLogic.h

+ removeCloudLogicForKey:

Removes the helper client associated with the key and release it.

+ (void)removeCloudLogicForKey:(NSString *)key

Parameters

key

A string to identify the helper client.

Discussion

Swift

AWSCloudLogic.removecloudLogicForKey("USWest2cloudLogic")

Objective-C

[AWSCloudLogic removecloudLogicForKey:@"USWest2cloudLogic"];

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

Declared In

AWSCloudLogic.h

– invokeFunction:withParameters:completionBlock:

Invokes the specified AWS Lambda function and passes the results and possible error back to the application asynchronously.

- (void)invokeFunction:(NSString *)name withParameters:(nullable id)parameters completionBlock:(void ( ^ ) ( id result , NSError *error ))completionBlock

Parameters

name

AWS Lambda function name, e.g., hello-world

parameters

The object from which to generate JSON request data. Can be nil.

completionBlock

handler for results from the function

Declared In

AWSCloudLogic.h