0

我目前无法使用AWS Mobile Helper在Swift中调用lambda。如何使用AWS Mobile Hub Helper调用lambda函数?

我已经成功配置我的项目中使用Cognito用户池和Cognito联合身份识别用户。

但现在调用lambda函数导致崩溃: terminating with uncaught exception of type NSException

飞机坠毁前有以下日志:

AWSiOSSDK v2.4.11 [Debug] AWSInfo.m line:122 | -[AWSServiceInfo  initWithInfoDictionary:checkRegion:] | Couldn't read the region configuration from Info.plist for the client. Please check your `Info.plist` if you are providing the SDK configuration values through `Info.plist`. 
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The service configuration is `nil`. You need to configure `Info.plist` or set `defaultServiceConfiguration` before using this method.' 

这里是代码:

let lambda = AWSLambda.defaultLambda() 

lambda.invoke(myRequest, completionHandler: { 
      (myAnswer: AWSLambdaInvocationResponse?, error: NSError?) in 

    print("ERROR HERE: \(error)") 
    let payload = myAnswer?.payload 
    print("PAYLOAD HERE: \(payload)") 

}) 

回答

1

如果您正在使用Mobile Hub或Mobile Hub Helper时,应使用它提供的类。当您实例化CloudLogic单例时,它将设置服务配置。

因此,而不是AWSLambda.defaultLambda你应该使用AWSCloudLogic.defaultCloudLogic它的方法会尽快进行实例管理权限问题。

您可以通过使用移动集线器下载使用云逻辑的示例应用程序来获得示例。

我放在一起移动枢纽

mobile hub diagram

+0

谢谢布鲁斯的简图。我已经阅读过你的精彩PDF。这是否意味着我必须实现其他的东西只是为了调用lambda函数? – Domsware

+0

我跟随你的示例,将东西添加到Info.plist。事情更进一步,但仍然有一个崩溃,并且这个日志:'***终止应用程序由于未捕获的异常'NSInternalInconsistencyException',原因:'服务配置是'nil'。在使用这种方法之前,您需要配置Info.plist或设置defaultServiceConfiguration。'' – Domsware

+0

我比较了您的示例和AWS给出的示例,尝试了解缺少的要点。他们真的不同! – Domsware