5

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

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

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

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

提前致谢。

4

1 回答 1

4

据我所见,MKStoreKit 以以下方法将您的产品列表作为 plist 检索MKStoreManager.m

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

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

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

例如,您可以有一些预填充的 .plist,然后像 NSDictionary 一样将其移动到 NUSUserDefaults,并且当来自 Server 的新项目到来时,您只需对其进行更新。

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

- (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"];
    }
于 2012-04-10T21:09:54.373 回答