iCloud 使用户“窃取”数据成为可能应用内消耗品

发布于 2024-12-10 07:41:04 字数 677 浏览 0 评论 0 原文

在我的应用程序中,用户购买存储在核心数据中的消耗品,比如说手提箱。当用户第一次安装该应用程序时,我会向他们提供免费赠品以供他们使用。如果没有至少设置一个手提箱,该应用程序将无法运行。

但如果用户在 iPhone 上安装该应用程序,然后在 iPad 上安装该应用程序并同步两者,那么他们现在就有 2 个手提箱。如果他们在任一设备上卸载该应用程序,然后重新安装并同步它,他们就获得了一个额外的应用程序,并且可以无限期地这样做。

我可以看到两种解决方案,但它们似乎都不正确:

  1. 当用户首次与 iCloud 同步时,向 NSUbiquityKeyValueStore 添加一个值。首次启动时检查该值。如果为零,则创建免费赠品,如果不是,则同步数据。但这会产生一个问题。如果用户在首次启动时禁用 iCloud 或没有互联网连接怎么办?该应用程序将创建免费赠品,然后当 iCloud 可用时,同步副本,他们可以根据需要多次执行此操作。

  2. 以某种方式匹配每个应用程序上的默认项目。我有匹配 objectID 或时间戳的想法,但这些会有所不同,我不确定如何处理它。

有谁知道我能对此做些什么吗?

编辑:

使用预打包的数据库加上 migratePersistentStore:toURL:options:withType:error: 似乎是要走的路。如果它对我有用,将发布带有代码的答案。

In my app, users purchase consumables, let's say suitcases, that are stored in Core Data. When the user first installs the app, I give them a freebie to get started. The app can't function without at least one suitcase set up.

But if the user installs the app on their iPhone and then their iPad and syncs the two, they now have 2 suitcases. And if they uninstall the app on either device, then reinstall and sync it, they've just gained an extra one and they can do that indefinitely.

I can see two solutions, but none of them seem right:

  1. Add a value to NSUbiquityKeyValueStore when the user first syncs with iCloud. Check this value on first launch. If it's nil, create the freebie, if it's not, sync data. But this creates a problem. What if the user disables iCloud or has no internet connection on first launch. The app would create the freebie, then when iCloud is available, sync the duplicate, and they could do this as many times as they like.

  2. Somehow match the default items on each app. I had the idea of matching objectIDs or timestamps, but these would vary and I'm not sure how to handle it.

Does anyone know anything I could do about this?

EDIT:

Using a prepackaged database plus migratePersistentStore:toURL:options:withType:error: seems to be the way to go. Will post an answer with code if it works for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

懒猫 2024-12-17 07:41:04

如果您不验证收据并跟踪用户在您自己的服务器上拥有的消耗品,那么您就做错了。您基本上相信用户是正派和诚实的,这通常总是一个坏主意。

当您使用应用内消耗品时,您应该在服务器上保存用户购买的内容的日志。这样,每次您的应用程序启动时,它都可以向服务器验证是否存在预期数量的消费品。

If you're not validating receipts and keeping track of what consumables users own on your own servers you're doing it wrong. You're basically trusting the user to be decent and honest, which is generally always a bad idea.

When you use in-app consumables you should be keeping a log on a sever somewhere of what your users has purchased. That way, every time your app starts up it can verify with the server that the expected number of consumable goods are present.

呆° 2024-12-17 07:41:04

使用 iCloud 意味着网络连接。一旦设备连接到网络,您就可以在您自己的服务器上验证收据并记录消耗品的消耗情况。

Use of iCloud implies network connectivity. As soon as a device connects to the network, you can validate receipts and log consumption of a consumable on your own servers.

日久见人心 2024-12-17 07:41:04

在我看来,最好的解决方案是将 UDID 存储在 iCloud UbiquitousKeyValueStore 的数组中。

//Store UDID in iCloud
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 5.0) {
    if ([[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]) {
        NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];

        //Get array
        NSMutableArray *devices = [NSMutableArray arrayWithArray:[store arrayForKey:@"UDID"]];
        [devices addObject:[[UIDevice currentDevice] uniqueIdentifier]];

        //Create new array, set to kvstore
        NSArray *newDevices = [NSArray arrayWithArray:devices];
        [store setArray:newDevices forKey:@"UDID"];
        [store synchronize];
    }
}

...

   //Check if app already installed on device
   NSArray *devices = [[NSUbiquitousKeyValueStore defaultStore] arrayForKey:@"UDID"];

    for (NSString *UDID in devices) {
        if ([UDID isEqualToString:[[UIDevice currentDevice] uniqueIdentifier]]) {
              //stop the giveaway
        }
    }

The best solution to this, in my opinion, is to store UDIDs in an array in iCloud UbiquitousKeyValueStore.

//Store UDID in iCloud
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 5.0) {
    if ([[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]) {
        NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];

        //Get array
        NSMutableArray *devices = [NSMutableArray arrayWithArray:[store arrayForKey:@"UDID"]];
        [devices addObject:[[UIDevice currentDevice] uniqueIdentifier]];

        //Create new array, set to kvstore
        NSArray *newDevices = [NSArray arrayWithArray:devices];
        [store setArray:newDevices forKey:@"UDID"];
        [store synchronize];
    }
}

...

   //Check if app already installed on device
   NSArray *devices = [[NSUbiquitousKeyValueStore defaultStore] arrayForKey:@"UDID"];

    for (NSString *UDID in devices) {
        if ([UDID isEqualToString:[[UIDevice currentDevice] uniqueIdentifier]]) {
              //stop the giveaway
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文