iOS
- 1 ответ
- 0 вопросов
1
Вклад в тег
Parse.Cloud.define("getTokenByVkId", function(request, response) {
Parse.Cloud.useMasterKey();
var vkId = request.params.vkId;
if(!vkId) {
response.error("wrong parameters");
return ;
}
var query = new Parse.Query(Parse.User);
query.equalTo("vkId", vkId);
query.first({
success: function(user) {
response.success(user.getSessionToken());
},
error: function(error) {
response.error(error.description);
}
});
});
//call parse cloud function
[PFCloud callFunctionInBackground:@"getTokenByVkId"
withParameters:@{@"vkId": vkUserId}
block:^(NSString* token, NSError *error) {
if (!error){
[PFUser becomeInBackground:token block:^(PFUser *user, NSError *error) {
<#code#>
}];
}else{
//TODO: handle error
}