views:

56

answers:

3

Hello. If I have an app that supports Game Center and I'd like to provide Achievements for completing a puzzle pack that's sold as an in-app purchase, how do I sync the iTunes account that's being charged for the in-app purchase with the Game Center user account that's doing the buying? As I understand it, they're two separate user accounts that are accessed in two different locations (The Game Center account is accessed in the Game Center app and the iTunes account is accessed in the Settings app).

How do I avoid this from happening...

  1. Game Center Player1 logs in, runs my app and purchases a puzzle pack
  2. Game Center Player1 logs out, Game Center Player2 logs in, runs my app and plays to completion the puzzle pack that Player1 purchased and Player2 is awarded the Achievement.
  3. Game Center Player2 logs out, Game Center Player1 logs in and finds the puzzle pack he/she purchased as already completed, so Player1 is unable to gain that same achievement.

Am I misunderstanding something with how these user accounts work? If not, is there a way to sync a Game Center account with an iTunes account as players log in and out of my game? Is there any kind of a work around for this problem? This seems like it would be a fairly common issue with any multiplayer games that sell content.

Thanks so much!

+1  A: 

That is a good question. :) As far as achievements go, I guess you could store them on the device with the playerId from the logged in GKPlayer, and once an achievement has been finished for a logged in player, you synch with Game Center.

As far as synching iTunes and Game Center accounts I really don't know. Usually you store some information on whether a purchase has been made (i.e. a feature available) on the device. Would it be logical that using that feature (or being allowed to use it) should be device dependent, not GC user dependent? But then what happens if someone uses their account to just download your content again and again to their friends' devices?

Hmm... I hope some other people will share their thoughts on this. But I found that Game Center questions receive very low views and answers :(

Joseph Tura
heh, I've noticed the same :) thanks for your thoughts, tho. I don't think you can make this kind of data device dependent since you have to allow all purchased content to be used on multiple devices by same iTunes user. I think I'm just gonna go with what the docs say and allow different GC players to access the same paid content, until someone else comes up with a better idea.
BeachRunnerJoe
Sorry, I didn't even mean that. I meant iTunes account dependent, but accepting that even that users logs out on the device, the content would still be available on that device. Works the same way for apps and music, right, unless you synch your device with another account. Let me know when you are done with your game. Curious to know how it turns out :)
Joseph Tura
True, that's a very good point. There's no real way to check if something's been purchased by the currently logged in iTunes user, except to do a full restore of all purchased content when your app starts, or something like that.
BeachRunnerJoe
+1  A: 

I am trying to come up with the solution to resolve this issue as well. If using the server product delivery mode, the problem could be largely resolved. The application sends the purchased items to server;sever deliver the item to application after checking credentials. There are some corner cases I still don't know how to resolve, basically to handle the case when the whole flow is interrupted, which depeneds on the implementation of IAP. Still not 100% sure yet.

beeeefy
Yeah, I was thinking about using the server model as a solution as well and I agree, that would definitely be a solution to this problem. The problem is, that's adds a whole new project, along with a whole new set of bugs and costs, to the iPhone app I'm trying to build. The greatest benefit of using the In-App Purchases framework and Game Center framework, and developing for the iOS platform in general, is all the server-side infrastructure that Apple has already built and allows you to use for free (or $99/year, that is). So I'd really like to use the built-in model for delivering content.
BeachRunnerJoe
But you would still store the content on the device, right? That is how I am doing it. 1. Buy from store. 2. Send receipt to own server 3. Server checks with App Store and sends confirmation and content to app 4. App stores content. --- But that process is only done once. What you could do, if you absolutely wanted to limit the purchase to a Game Center account, is send the GKPlayer.playerId to your server, store that in a db, and the next time someone wants to install that content, although the app store confirms it has been bought, refuse delivery if ...
Joseph Tura
...the game center user is different. But I doubt Apple will allow that.
Joseph Tura
@Joseph: Two questions 1)How difficult was it to setup the server you use? 2) How necessary do you find it to be? I wasn't planning to do this since it seems very optional.
BeachRunnerJoe
I am not storing anything in a database. So basically I am sending a request to the App Store to verify, and then send a JSON response to the app with the content. It's sort of hacked together, but only about 10 lines of code. I did not want to store the content in the app, because I wanted to be app store independent with content updates.
Joseph Tura
Gotcha, thanks!
BeachRunnerJoe
+1  A: 

So here's how I'm going to do this, it's actually a fairly straightforward approach. I'm going to locally track users progress in the purchased puzzle packs using core data, since it's quick to get up and running. Each time a new GC user logs in, I'll create a new user object and track their progress in the puzzle packs and report the achievements in GC when needed. When that GC user logs in later, I'll just adjust the state of the puzzle packs to match their current progress defined in core data. This way, any iTunes account can purchase the puzzle packs and they'll inherently be available to anyone using the device. Whenever any GC users log into GC and play my app, they'll all have access to the same purchased puzzle packs, but their progress and achievements will be maintained independently of other GC users.

If GC isn't installed on the device, I can disable all GC features and just init the app as tho there's only one default player.

Should be simple to do.

BeachRunnerJoe
I still see one unsolved problem: Apple explicitly state that developers should not make any assumptions as to the format of the playerId string. Which probably means they might change it some time in the future. If they do, how are we supposed to identify a user locally? Your approach seems perfectly valid to me, it is just a potential flaw in Apple's system.
Joseph Tura
Good point, I gotta think about this. It's strange Apple actually recommends using this piece of data to store persistent data, "The player identifier should not be displayed to the user. Your application should use this string whenever it needs to persistently store information for a specific player. Do not make assumptions about the contents of the player identifier string. Its format and length are subject to change." - Apple
BeachRunnerJoe
@Joseph, I think what Apple is saying is that the format and length of one player identifier may be different than another player's identifier. In other words, once a player has an identifier, it won't change. This would make sense since they actually recommend using the player identifier to store persistent data.
BeachRunnerJoe
You are probably right, now that I think about it that makes a lot more sense ;)
Joseph Tura