gpt4 book ai didi

iphone - 使用 MKStoreKit 实现动态服务器产品列表?

转载 作者:可可西里 更新时间:2023-11-01 04:42:34 26 4
gpt4 key购买 nike

我正在我的应用程序中实现 MKStoreKit,但该应用程序的性质决定了它需要支持对应用程序内购买的可用(非消费)产品列表进行频繁、动态的更改。因此,我需要能够定期查询我们的服务器以获取可用产品 ID、描述等的当前列表。

据我所知,MKStoreKit 仅支持可用产品的静态 plist,这意味着我们每次需要更改 IAP 产品列表时都必须发布应用程序更新。正如我所提到的,此服务无法做到这一点。

有谁知道使用 MKStoreKit 从服务器下载更新我们的 IAP 产品列表而不需要更新应用程序的方法。

如果没有,我不得不想象有人修改了代码来支持它。如果是这样,我们将不胜感激获得的任何提示和智慧。

提前致谢。

最佳答案

据我所知,MKStoreKit 在 MKStoreManager.m 的以下方法中将您的产品列表检索为 plist:

#pragma mark Internal MKStoreKit functions
//line 201 of MKStoreManager.m

- (NSDictionary*) storeKitItems
{
return [NSDictionary dictionaryWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MKStoreKitConfigs.plist"]];
}

因此,如果您只是更改此方法调用,例如,从您的服务器获取新项目,您可以获得所需的结果。

例如,您可以有一些预填充的 .plist,然后将其移动到 NUSUserDefaults,就像 NSDictionary 一样,当来自服务器的新项目到来时,您只需更新它。

所以,你的方法看起来像这样:

- (NSDictionary*) storeKitItems
{
if(![[NSUserDefaults standardUserDefaults]valueForKey:@"NewConfigs"])
[[NSUserDefaults standardUserDefaults]setValue:[NSDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MKStoreKitConfigs.plist"]]] forKey:@"NewConfigs"];
[[NSUserDefaults standardUserDefaults]synchronize];

return [[NSUserDefaults standardUserDefaults]valueForKey:@"NewConfigs"];
}

关于iphone - 使用 MKStoreKit 实现动态服务器产品列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9233718/

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