【发布时间】:2015-02-18 13:30:14
【问题描述】:
我正在尝试将订阅添加到特定 PFUser 的所有 PFInstallations(对于一个人在 iPhone iPad 上使用相同登录的情况等)。我有他们所有使用该应用程序的 Facebook 朋友的表格视图。在选择行中的朋友时,我希望它获取我的 objectId 并查询所有 PFInstallations 以获取关键 usersObjectId 与 PFUser objectId 匹配的所有 PFInstallations 的数组。然后,我可以为每个 PFInstallations 的通道添加一个值。我有:
FriendArray *job = self.jobsArray[indexPath.row];
PFQuery *query = [PFUser query];
//job.facebookid is the Facebook id for that particular user
//each PFUser has a fbId and for those who logged in with Facebook, their Facebook ID is stored here
[query whereKey:@"fbId" equalTo:job.facebookid];
PFUser *user = (PFUser *)[query getFirstObject];
//This gives me the PFUser whose fbId value matches the Facebook id for the row that was selected
NSString *subscription = [@"User_" stringByAppendingString:user.objectId];
PFUser *me = [PFUser currentUser];
PFQuery *pushQuery = [PFInstallation query];
//Trying to get all PFInstallations that match the current user's usersObjectId, so I can add the value to each channel
[pushQuery whereKey:@"usersObjectId" equalTo:[me objectId]];
PFInstallation *allInstallations = (PFInstallation *)[pushQuery findObjects];
[allInstallations addUniqueObject:subscription forKey:@"channels"];
不过,它告诉我不能直接查询 PFInstallation。如何在云代码中做同样的事情?
【问题讨论】:
-
您需要帮助将整个块转换为 Cloud Code 还是其中有错误?
-
错误告诉我,我不能直接查询 PFInstallation,所以我知道它必须在云代码上完成,只是不确定如何。到目前为止,我有:
Parse.Cloud.define("subscribingAll", function(request, response) { var usersObjectId = request.params.usersObjectId; var newSubscription = request.params.newSubscription; var pushQuery = new Parse.Query(Parse.Installation); pushQuery.equalTo("usersObjectId", usersObjectId); });我只是不确定如何从这里开始使用每个 PFInstallations 中的查询和更新键 -
嗯,不知道我能帮你多少。你有没有看过docs看看你是否能找到你需要的东西?
-
@lightice11 我看过它们,但看不到在 javascript 中我可以在哪里获取返回的安装文件并进行编辑。
-
来自解析文档:
Note that Installation data can only be modified by the client SDKs, the data browser, or the REST API.
标签: ios parse-platform pfquery parse-cloud-code