StoreKit to return all product IDs

2020-07-05 07:31发布

问题:

This question is a little different from the others I've found here. My In App StoreKit is working, I can list products in my store successfully. I've gone through the Apple documentation and never saw my question addressed(I may have missed it).

My client(non-profit) would like to be able to accept donations through their App. I would like to let them have the ability to add new donation events on the fly without users having to update their app. What I mean is, they may have a special "Help us sponsor an event this upcoming Arbor Day" and accept donations particular to that case.

I am currently reading products like this:

SKProductsRequest *request= 
         [[SKProductsRequest alloc] initWithProductIdentifiers: 
          [NSSet setWithObjects: @"goldSponsor", @"silverSponsor"];

This means if that Arbor Day event comes up, I'll have to issue an update to include the @"arborSponsor" in my request list. How can I request every product under my bundle?

I've tried using @"com.thedomain.*" and some other guesses without luck. Is it possible to return the whole list, am I missing something very simple? Thanks!

回答1:

You unfortunately have to provide all of the ID's for products you'd like to get information for as far as I could see.

One way to handle this is to store your product ID's on a remote server and then to make a request to the server to pull down the current set of ID's when loading the store.

That would allow you to add or remove products from the itunes side of things and not have to submit any binary updates to your app.

I think you could probably find a happy medium by caching the list of products in the iphone app and then just making a quick request to see if there had been any changes so you wouldn't even have to get the full list each time.

This could be done using a simple http API on the server side or even just an xml file you pull down.

From the In App purchase Programming Guide

Apple recommends you retrieve product identifiers from your server, rather than including them in a property list. This gives you the flexibility to add new products without updating your application.



回答2:

I have the same problem but I think I have a way to solve it by planning ahead with the product IDs. Instead of naming each product ID something special like "goldSponsor", just number them "1", "2", "3" ... for as many as you want to add. Set the name to "Gold Sponsor" and the description to whatever you want. When your app starts running, request the first N sequential product IDs. If they all are returned as valid, request another N product IDs until you get invalid IDs at which point you are done.

I am planning to do this with Apple hosted content. I am also considering using the description field for the product to encode detailed information about the data I am downloading (in my case the corner coordinates of a map). I will still be using the full "com.company.product.1" for each ID and numbering them sequentially from there.



回答3:

No, you can't get all products from App-store without IDs

Depend on Apple Documentation