Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my iOS project, I need to implement the AWS SDK, as I successfully did in the Android version of that project.

I imported AWSMobileClient and AWSAPIGateway in my iOS project using Cocoapods.

Here is what I did in my Android project, that I want to replicate on iOS:

  • I created an AWSInterface interface, where all my api endpoints are:
@Service(endpoint = "https://abcde12345.execute-api.eu-central-1.amazonaws.com/dev")
interface AWSInterface
{
    @Operation(path = "/api-demo", method = "POST")
    fun apiDemo(
        @Parameter(name = "Content-Type", location = "header") contentType: String,
        body: ApiDemoModel): RetourStatutWS
}
  • and here is the ApiDemoModel, very simple:
class ApiDemoModel(val code: String)
  • I created an AWSInterfaceHolder class, so I'll be able to call apis:
class AWSInterfaceHolder
{
    var awsInterface: AWSInterface = ApiClientFactory()
        .credentialsProvider(AWSMobileClient.getInstance())
        .clientConfiguration(ClientConfiguration().withConnectionTimeout(30000))
        .build(AWSInterface::class.java)
}
  • I call my api, after a successful initialization of AWSMobileClient:
// AWSMobileClient is successfully initialized, I can call my api:
val awsInterfaceHolder = AWSInterfaceHolder()
awsInterfaceHolder.awsInterface.apiDemo(
    "application/json",
    ApiDemoModel("123456"))

How can I do the same for my iOS Swift project?

Thanks.

question from:https://stackoverflow.com/questions/66049702/how-to-call-an-aws-webservice-api-gateway-on-ios

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
179 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...