[英]How to recreate deleted installation table at parse.com
I accidentally dropped the Installation
table in the parse.com data browser. 我不小心将
Installation
表放在了parse.com数据浏览器中。
This table contained device data of my iOS users. 该表包含我的iOS用户的设备数据。 With the device ID´s missing , i can´t send the users any push notifications .
由于缺少设备ID ,我无法向用户发送任何推送通知 。
The only way I know to recreate a installation row is to delete and reinstall the app . 我知道重新创建安装行的唯一方法是删除并重新安装该应用程序 。 But this is no option because it totally breaks the user experience.
但这不是选择,因为它完全破坏了用户体验。
Is there a way to recreate the rows of the installations table from the objective C code? 有没有一种方法可以从目标C代码重新创建安装表的行?
Or anyway access the installationID and deviceToken, in that case so I would recreate the table per hand. 还是无论如何都访问installationID和deviceToken,在这种情况下,我将每手重新创建表。
As all other methods did not work, i updated my app in a way that saves all data of the currentInstallation
in a backup table. 由于所有其他方法均不起作用,因此我以一种将
currentInstallation
所有数据保存在备份表中的方式更新了我的应用程序。
PFObject *backupInstallation = [PFObject objectWithClassName:@"installationRecovery"];
for (NSString *key in [PFInstallation currentInstallation].allKeys) {
// Filter out the basic keys.
if (![@[@"objectId", @"createdAt", @"updatedAt"] containsObject:key]) {
[backupInstallation setObject:[PFInstallation currentInstallation][key] forKey:key];
}
}
[backupInstallation saveInBackground];
After i got all installation entries, i manually added the missing ones to the Installation
table. 在获得所有安装条目后,我将缺少的条目手动添加到“
Installation
表中。 Although the objectId
´s did not match the ones in the local entries, i got the push notifications to work. 尽管
objectId
的与本地条目中的不匹配,但是我得到了推送通知。
You can also handle the copy job by writing a cloud function that does it for you. 您还可以通过编写为您完成的云功能来处理复制作业。 This could be triggered in a post save hook of
installationRecovery
. 这可以在
installationRecovery
的后保存钩中触发。
I also made shure that this code only executes once on update. 我还确保该代码仅在更新时执行一次。 By checking a user default setting.
通过检查用户默认设置。
NSString *backuppedInstallation = [[NSUserDefaults standardUserDefaults] boolForKey:@"backuppedInstallation"];
if (!backuppedInstallation) {
// Your code here
[[NSUserDefaults standardUserDefaults] setBool:@(YES) forKey:@"backuppedInstallation"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.