我正在尝试用swift构建一个iPhone应用程序,我已经安装了所有依赖于“连接到你的后端”https://docs.aws.amazon.com/aws-mobile/latest/developerguide/add-aws-mobile-nosql-database.html,我甚至有amazon aws登录页面所以它是def连接的,只是当我添加这一行时: let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default() 它告诉我在教程中做的,应用程序在屏幕上崩溃,代码与线程1:SIGABRT相关联。这是我在屏幕上的代码。
import UIKit
import MapKit
import AWSCore
import AWSAuthUI
import AWSMobileClient
import AWSUserPoolsSignIn
import AWSDynamoDB
class SampleViewController: UIViewController, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default()
if !AWSSignInManager.sharedInstance().isLoggedIn {
presentAuthUIViewController()
self.navigationController?.isNavigationBarHidden = true
}
}
@IBAction func askPermission(_ sender: UIButton) {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func presentAuthUIViewController() {
let config = AWSAuthUIConfiguration()
config.enableUserPoolsUI = true
AWSAuthUIViewController.presentViewController(
with: self.navigationController!,
configuration: config, completionHandler: { (provider: AWSSignInProvider, error: Error?) in
if error == nil {
// SignIn succeeded.
} else {
// end user faced error while loggin in, take any required action here.
}
})
}
}
我很感激任何帮助,如果需要可以发布更多信息。非常感谢你。
答案 0 :(得分:0)
是否可以在定义“DynamoDBObjectMapper”的部分之后将以下内容添加到awsconfiguration.json中。将下面的“YourRegion”占位符替换为数据库所在的区域。这是awsconfiguration.json文件中的必需部分,并且可能存在生成配置的工具中的错误。
"DynamoDB": {
"Default": {
"Region": "YourRegion"
}
},