来自Parse.com的元数据

时间:2015-02-24 23:14:28

标签: parse-platform mbaas

如果应用程序配置为使用单独的应用程序ID /机密连接到Parse服务器上的不同实例,那么验证应用程序是否已连接到Parse上的正确实例的最佳方法是什么。基本上它是在实际尝试写入/读取存储在后端的对象之前提取某种元数据。

我目前正在使用iOS SDK,Parse.h/PFObject.h/PFQuery.h不包含任何此类信息。

我在查询应用程序ID时尝试的东西,并尝试将其与环境的预定义值匹配。有没有更好的方法呢?

1 个答案:

答案 0 :(得分:1)

看看PFConfig。您可以在每个Parse实例中设置唯一的配置参数。

以下是如何使用它的快速示例:

NSLog(@"Getting the latest config...");
[PFConfig getConfigInBackgroundWithBlock:^(PFConfig *config, NSError *error) {
  if (!error) {
    NSLog(@"Yay! Config was fetched from the server.");
  } else {
    NSLog(@"Failed to fetch. Using Cached Config.");
    config = [PFConfig currentConfig];
  }

  NSString *welcomeMessage = config[@"welcomeMessage"];
  if (!welcomeMessage) {
    NSLog(@"Falling back to default message.");
    welcomeMessage = @"Welcome!";
  }
  NSLog(@"Welcome Messsage = %@", welcomeMessage);
}];
相关问题