Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing dynamic server product list with MKStoreKit?

I'm implementing MKStoreKit in my app, but the nature of the app is such that it will need to support frequent, dynamic changes to the list of available (non-consumable) products for in app purchase. Thus, I need to be able to regularly query our server for the current list of available product IDs, descriptions, etc.

As far as I can figure, MKStoreKit only supports a static plist of available products, which would mean we'd have to release an app update every time we need to change our IAP product list. As I've mentioned, this is not possible with this service.

Does anyone know of a way to update our IAP product list by downloading it from the server, without requiring an app update, using MKStoreKit.

If not, I have to imagine there are people out there who have modified the code to support this. If so, any tips and wisdom gained would be MUCH appreciated.

Thanks in advance.

like image 291
Murdock Avatar asked Oct 08 '22 17:10

Murdock


1 Answers

As far as i can see, MKStoreKit retrieves the list of your products as a plist in the following method of MKStoreManager.m:

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

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

So, if you just change this method call, for example, to get the new item from your server, you can achive the result you need.

For example, you could have some prepopulated .plist, and then move it NUSUserDefaults, just like an NSDictionary, and, when the new items from Server come, you just update it.

So, your method would look something like this:

- (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"];
    }
like image 61
Nikita Pestrov Avatar answered Oct 19 '22 23:10

Nikita Pestrov