Reputation: 587
Currently, my iOS app has to ask my server for the in-app purchase products available, and then afterwards, for the products, the app has to ask Apple for their prices.
The added delay for this is probably not much, but I'd like to make it faster.
Can I not use my server to fetch those prices instead of the client? That is, is there an HTTP-based API that I can use from the server to get the prices for me rather than the client? That way I can cache the results for different users and reduce the round trip time. If so, how can I do this? If not, in what ways are you handling this?
Upvotes: 2
Views: 1722
Reputation: 3752
****Client**-iOS App DS-Developer Server AppleS-Apple Server**
Client communication with both DS & AppleS
When the Client communicates with the AppleS you have a couple of advantages (as mentioned below) against a single disadvantage of time consumption.
When u send a set of In-App-Products to AppleS, it matches the one's valid & sends an array list of valid Product ID's (SKProduct Array). This completely eliminates the risk of displaying products which have not yet been registered, approved & cleared for sale against your app.
Localization - Price as an example. S'pose I'm selling a product in US & UK. The price for this product will be in terms of say US $ in DS. So you end up showing the user in UK the price in US $. (In order to overcome this only up-to somewhat extent DS shall have a mechanism to localize the currency based on the user's country).
Client communication with only DS
To answer your question; Yup, u can use DS to fetch the price of the product. You achieve this by adding another attribute (price) to product object(from the list of in-app purchase products available from your server). Needs to be implemented at DS.
For Eg.
Product1 - in-app-product ID, Price, Name, Sample Image, etc.
.
.
Product n - in-app-product ID, Price, Name, Sample Image, etc.
Okay now how do we try to incorporate the couple of advantages from Client communicates with both DS & AppleS while using Client communication with only DS?
1 Adv - By manual check at DS end or through some defined process one can make sure that only valid products are displayed.
2 Adv - To incorporate this up-to somewhat extent implement the following @ DS
Step 1–Create a DB table at DS end having the App Store pricing Matrix.
Step 2–When u hit a request from Client to DS, your DS can get the IP from service request hit. Depending on this DS service can find current country of User.
Step 3–Based on current country of the User, map the price in the localized currency from Step 1. In case current country of user is not a part of App Store pricing Matrix use the US$ price.(This is somewhat close to what apple does, though it uses country associated with Apple ID of the User).
End result localized price displayed in IAP Confirmation Dialog will be same as price displayed by you (avoiding the mismatch as pointed out by you - somewhat again :-)).
This whole implementation will fail in a scenario when a user belonging one country has an AppleID belonging to some other country. It fail's coz DS maps price depending on location of user but IAP Confirmation Dialog shows price based country of the user's AppleID (Mismatch !!!).
U can't determine Country associated with Apple ID logged into the iOS device. Check this Q&A.
I suggest you go implement 'Client communication with both DS & AppleS' model, however in order to reduce the delay associated when the Client communication with both DS & AppleS, have multiple product request(say a set of 10 products at a time or depending on how many products u display at a time in ur UI).
Only in case if you feel or more precisely have an analysis which say's you are bound to lose out revenue or the user because of the "delay" then go ahead with 'Client communication with only DS' model.
Upvotes: 1
Reputation: 6302
You could just have an array with the prices/data stored on your server in US$ and then localize them from within the app again. If you add more products or change your prices later then just update your array, whatever its just one file sitting on a server. Of course the localization might take a while, I'm not sure if there is code to support it so putting in a dollar-equivalent for each country would definitely be time consuming but possible. End result would be much faster though, I have fetched my product ids like this and its UBER quick in comparison.
If you still get the prices from your server then have the app send the local through first and attach it to your request so that the price results can be localized.
Upvotes: 1