如何在parse.com上重新创建已删除的安装表 [英] How to recreate deleted installation table at parse.com

查看:66
本文介绍了如何在parse.com上重新创建已删除的安装表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心在parse.com数据浏览器中删除了Installation表.

I accidentally dropped the Installation table in the parse.com data browser.

此表包含我的iOS用户的设备数据.在设备ID丢失的情况下,我无法向发送用户任何推送通知.

This table contained device data of my iOS users. With the device ID´s missing, i can´t send the users any push notifications.

我知道重新创建安装行的唯一方法是删除并重新安装该应用.但这没有选择,因为它完全破坏了用户体验.

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.

是否可以通过目标C代码重新创建安装表的行?

Is there a way to recreate the rows of the installations table from the objective C code?

在这种情况下,还是要访问installationID和deviceToken,所以我将手动创建该表.

Or anyway access the installationID and deviceToken, in that case so I would recreate the table per hand.

推荐答案

所有其他方法不起作用,我以一种将currentInstallation的所有数据保存在备份表中的方式更新了我的应用.

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.

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];

获得所有安装条目后,我将缺少的条目手动添加到Installation表中.尽管objectId与本地条目中的不匹配,但我得到了推送通知.

After i got all installation entries, i manually added the missing ones to the Installation table. Although the objectId´s did not match the ones in the local entries, i got the push notifications to work.

您还可以通过编写为您完成的云功能来处理复印作业.这可以在installationRecovery的后保存钩中触发.

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.

我还确保该代码仅在更新时执行一次.通过检查用户默认设置.

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];
}

这篇关于如何在parse.com上重新创建已删除的安装表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆