首页 > 解决方案 > Xcode 11 使用 Parse 连接到 Amazon Web Service 时出错

问题描述

我正在尝试连接到我的 AWS 服务器,但是当我尝试在那里保存一个对象时,Xcode 无法到达并给我这个错误:

可选(错误域=解析代码=0“未授权”用户信息={错误=未授权,NSLocalizedDescription=未授权,临时=0})

这是我在 appDelegate 上的代码:

Parse.enableLocalDatastore()

    let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
        ParseMutableClientConfiguration.applicationId = "*******"
        ParseMutableClientConfiguration.clientKey = "****************"
        ParseMutableClientConfiguration.server = "http://ec2-3-22-186-169.us-east-2.compute.amazonaws.com/parse"
    })

    Parse.initialize(with: parseConfiguration)
    testParseSave()
    return true
}

func testParseSave() {
    let testObject = PFObject(className: "MyTestObject")
    testObject["foo"] = "bar"
    testObject.saveInBackground { (success, error) -> Void in
        if success {
            print("El objeto se ha guardado en Parse correctamente.")
        } else {
            if error != nil {
                print("is NOT nil:")
                print (error as Any)
            } else {
                print("IS nil:")
                print ("Error")
            }
        }
    }
}

提前致谢!

标签: swiftamazon-ec2parse-platformparse-serverparse-ios-sdk

解决方案


推荐阅读