用户,
我正在尝试将currentUser设置为Installation对象。我遵循AnyPic项目的代码逻辑,但只有在应用程序重新启动时才调用beforeSave方法。因此,如果有人安装了应用程序(ofc、atm、他没有经过身份验证),则CC中的request.user为null。
因此,当用户成功注册/登录时,我想我会调用[[PFInstallation currentInstallation] saveInBackground];。但不幸的是,beforeSave没有被调用。
我知道我也可以在客户端设置它,但是我希望将来能阻止它。
CC安装beforeSave
Parse.Cloud.beforeSave(Parse.Installation, function(request, response) {
Parse.Cloud.useMasterKey();
console.log("user"+request.user);
if (request.user) {
request.object.set('user', request.user);
} else {
request.object.unset('user');
}
response.success();
});调用iOS上的安装更新
[[PFInstallation currentInstallation] saveInBackground];发布于 2015-08-18 22:52:18
我认为当您调用saveInBackground时,它甚至不会请求保存对象,因为没有任何更改。
相反,在客户端,我设置用户,如果用户未登录,则取消设置,然后是saveInBackground。在CloudCode,我和您一样使用beforeSave来覆盖客户端的请求参数。
因此,您所需要做的就是在调用PFInstallation currentInstallation之前对saveInBackground进行任何更改。
https://stackoverflow.com/questions/23152221
复制相似问题