Question

How do I implement (Auto-renewable) Subscriptions for an Android App.

I've read the documentation

and as far as I understand, the process is the following:

  • User subscribes to such a subscriptions on the app. This will generate a Purchase token.
  • The app sends this token to the server along with something to identify this user
  • The server will store this Purchase token with this user and will mark the subscription as valid
  • the server validates this Purchase token via the http-api periodically (typically once per day) with something like a cronjob
  • if the subscription isn't valid anymore, the subscription will be marked as invalid on the server-side.
  • If the app makes requests to the server to resources that need the subscription, the client will send this user-identity-string along with the requests. We then check in the database, if the subscription of this user is still marked as valid.

My question is now, how we should identify this users? Do we have a simple user id available that we can share between our app and our server? or should we use something different? What is the best practice here?

We did already similar subscriptions on ios and we used the uuid of the device to identify the users (at least as long as we were able to use the uuid).


From the Answer below we should generate a unique ID. This would be unique per device (or per app-installation). But if a user changes his device or reinstalls the application this id would not be the same anymore. So I'm not sure, how the process is in this use case. I thought of something like this:

  • The user is logged in with the same google play account on his second device.
  • As the app starts (or becomes active) we would fetch the users subscriptions
  • We then would receive this purchase token from the subscriptions and send them along with the new unique-ID to our backend-server as if the user had made a new subscription.

Would this be the right process? And stays the purchase token the same as it was on the first device?


Ok, my question about identifiying users is answered, the link provided delivers enough informations. I'll put further questions in new threads on SO, if I have some.

Was it helpful?

Solution

This link maybe helpful to you as you want to identify the users uniquely.Please note that the personal information of a user rests with Google only.And you should avoid getting private information of a user. http://www.pocketmagic.net/2011/02/android-unique-device-id/#.URIe_B3Wgr7

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top