我正在我的应用程序中实现 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/