Saturday, March 2, 2013

In App Purchase product sequencing

One last minute change I had to make right before submitting Monster Cache for review was that the In-App Purchasing products on iPhone were displaying in what seemed like a random sequence.  For iOS, you send a request to the App Store for your available products, then it returns you a list of your products.  I iterated through the list in the order it was sent, and the order was not the sequence I wanted.

What was really happening is they were sorting based on their hidden product ID.  Well, I put numbers in those representing numbers of coins, like coins50, coins100, coins500, coins1000, etc.  As many people know from sorting music tracks with numbers, they don't sort numerically, they sort alphabetically, so 100 comes before 50 because it starts with 1 which is less than 5.

Once I figured that out, I considered trying to sort the array that they returned before I iterated through it, but it wasn't just the product ID's, it was an array of objects.  That seemed like too much hassle, so I just deleted and recreated half of my in app purchasing products to give the product ID's leading 0's, like coins0050. (You can't change a product ID once it has been set, which is why I had to delete and recreate).

No comments:

Post a Comment