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

标签 iphone ios in-app-purchase mkstorekit

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

相关文章:

ios - 取消 Apple 自动续订订阅

xcode - 我从苹果的沙箱服务器测试 ios 中的自动更新订阅时收到 21004 作为状态值的回复?

iphone - 如何获取字典数组中特定键的值?

ios - 加载链接到 xib 的自定义 UIView 的最佳方法

ios - SDWebImage 滚动时清除图像缓存?

IOS自动续订订阅状态获取不到

ios - 在调整 UIScrollView 大小时调整内容比例和偏移量

iphone - UIView 和 UIControl 在 UIScrollView 内拖动时的区别

iphone - Cocoa - 添加视频水印一般信息

ios - 在 iOS 7 中使用 Assets URL 获取图像 (UIImage)