gpt4 book ai didi

ios - 检测首次在 iOS 中安装 NOT NSUserDefaults

转载 作者:可可西里 更新时间:2023-11-01 03:58:23 25 4
gpt4 key购买 nike

工作原理 - 该应用是跨平台服务的订阅。在 iphone 上,首次购买将为您提供 30 天的完整功能,然后 30 天后您将无法执行某些操作,直到您通过应用内购买购买订阅。

我需要什么 - 我需要知道这是否是第一次运行,以便我可以将用户信息添加到数据库中。或者因为它是跨平台的,他们可能已经支付了订阅费用,所以我需要为用户现有的订阅增加 30 天。

我现在在做什么 - 目前我将 identifierForVendor 存储在远程数据库中,在 NSUserDefaults 中有一个 bool 值检查以查看 1. 如果它是第一次运行和 2. 如果它是第一次运行允许用户将自己添加到数据库中以进行 30 天的完整使用,或将 30 天添加到他们现有的订阅中。

问题 - 问题是,如果用户删除应用程序然后重新安装它,NSUserDefaults 也将被删除,identifierForVendor 将更改,这将允许用户再添加 30 天只需删除并重新安装应用程序即可免费订阅。

理想方案 本来想做app的订阅,但是不知道当初购买app时如何查看收据,将用户插入到远程数据库中。此外,我真的不知道如何设置非应用内购买的订阅。我还考虑过让应用程序免费,然后他们可以使用应用程序内购买来购买服务,但是如果无法连接到远程服务器以首先建立数据,应用程序就毫无用处。

底线我想执行以下操作之一

  1. 在第一次购买时进行订阅(我需要能够检测购买是否有效,以便将用户信息输入远程数据库)
  2. 让应用免费,然后使用应用内购买来添加订阅(是否可以接受免费应用在您订阅之前什么也做不了?)
  3. 保留它现在的样子(但是为 identifierForVendor 找到一个更永久的解决方案,identifierForAdvertising 也不会工作,因为它可以被关闭)

最佳答案

这对你很有帮助。基本上它是在 NSUserDefaults 之后设计的钥匙串(keychain)包装器。它帮助了我很多。将东西存储在 Keychain 中可以让它们在应用程序重新安装后保持不变。

https://github.com/carlbrown/PDKeychainBindingsController

This project is intended to make using the Mac OSX and iOS Keychains as easy as NSUserDefaults.

It is a KVO-compliant Cocoa wrapper around the Mac OSX and iOS Keychains, and the model for this wrapper is NSUserDefaults, so the intent is that for the common cases you would normally want to call:

[NSUserDefaultsController sharedUserDefaultsController] You should be able to call

[PDKeychainBindingsController sharedKeychainBindingsController] And for the common cases you normally would have called:

[NSUserDefaults standardUserDefaults] You should be able to call

[PDKeychainBindings sharedKeychainBindings]

关于ios - 检测首次在 iOS 中安装 NOT NSUserDefaults,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13996582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com