ios - 如何让 iOS 应用程序与我的 Parse Web 服务器通信?

标签 ios swift xcode parse-platform parse-server

我有一个网络服务器,其中的解析服务器示例运行如下:

var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/nimbus',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'nimbus',
masterKey: process.env.MASTER_KEY || 'emory',
serverURL: process.env.SERVER_URL || 'http://locahost:5010/parse',
liveQuery: {
classNames: ["Users"]
}

现在,我还通过以下方式配置了我的 iOS 应用程序 (didFinishLaunching):

Parse.setApplicationId("nimbus", clientKey: "X")
let player = PFObject(className: "User")
player.setObject("Richard", forKey: "Name")
player.setObject("O", forKey: "Password")
player.saveInBackground { (succeeded, error) -> Void in
if succeeded {
            print("Object Uploaded")
        } else {
            print("Error: \(error)")
        }
    }

然而,没有任何反应。如何将应用程序和我的服务器连接在一起?此外,由于 Parse 已经开源并放弃了托管,我可以使用任何 API key ,对吧?

最佳答案

How do I go about connecting the app and my server together?

连接 Parse iOS SDK你的应用程序与你的 Parse Server , 使用 ParseClientConfiguration 初始化您的 Parse SDK

例如:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    // Configuration of you parse application
    let configuration = ParseClientConfiguration {
        $0.applicationId = "MY_APP_ID" // Your App Id
        $0.server = "https://example.com/api" // The URL of your server
    }
    Parse.initialize(with: configuration)

    return true
}

I can use any API key right?

您不需要客户端 key 即可连接您的 Parse Server

希望我的回答对你有帮助

关于ios - 如何让 iOS 应用程序与我的 Parse Web 服务器通信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43540513/

相关文章:

ios - 向 UITableView 添加字幕数组

ios - 如何在数据加载之前延迟解析这些所需的变量?

iphone - 如何禁用 UIBarButtonItem?

ios - 从 Xamarin 中的代码隐藏创建 UIViewController

c++ - 在 swift 项目中桥接 objective-c 库不起作用

xcode - 如何使用LLDB打印内存地址的内容?

swift - NSCollectionView,Swift 4 - 无法调用 "register"

swift - 用通用类覆盖等于

xcode - 模型类生成已禁用 : disabled in project (CoreML Code Generation Language set to "none"

c++ - macOS 塞拉利昂 : __textcoal__nt is deprecated