我在 application:didFinishLaunchingWithOptions 中保存一个 PFInstallation 对象——我不是询问用户推送权限或任何与 deviceToken 相关的事情——我发现许多标准字段未填充,包括:
- 应用标识符
- 应用版本
- 应用名称
- 角标(Badge)
- 解析版本
- 时区
(这些列在数据浏览器中未定义,不会显示在 PFInstallation 对象的 NSLog 上。)
- deviceType 确实被填充
我正在抓取并成功将 deviceModel 和 deviceOS 保存到两个自定义列中。但我对为什么上述列未定义感到有点困惑。
代码如下:
[Parse setApplicationId:PARSE_APPID_DEV
clientKey:PARSE_CLIENTKEY_DEV];
// record device model and OS
NSString *model = [self getDeviceModelAndNumber]; // via sys/utsname.h
NSString *sysVersion = [[UIDevice currentDevice] systemVersion];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
PFUser *loggedUser = [PFUser currentUser];
if (loggedUser)
[currentInstallation setObject:loggedUser forKey:@"user"];
[currentInstallation setObject:model forKey:@"deviceModel"];
[currentInstallation setObject:sysVersion forKey:@"deviceOS"];
NSLog(@"installation: %@", currentInstallation);
[currentInstallation saveInBackground];
这个项目是在 Xcode 6 中创建的。在一个不同的项目中,在 Xcode 5 中创建,我基本上做同样的事情,并且正确地填充和保存了列。
还有其他人遇到过这个吗?我用谷歌搜索了很多但没有找到解决方案。非常感谢任何帮助。
最佳答案
经过多次实验,似乎(显着地)将最后一行更改为
[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
// some logging code here
}];
解决问题。所以我想我应该用 Parse 提交一个错误。 (其实已经有一个打开了:https://developers.facebook.com/bugs/712949858787516/)
关于ios - 保存 Parse PFInstallation 对象时缺少字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26691295/