Google Licensing questions

During my attempts to incorporate the google licensing I had read through google’s reference a couple times. Reading how it is designed to work it leaves me with questions on Corona’s implementation. There is little documentation on what is really going on under the hood with Corona.

According to google if using serverManaged the license comes with an expiration and once verified the app should not attempt another check until the expiration is expired. Further checks after that also have retries if there are failures to connect, before it should be considered unlicensed.

From what I can tell, Corona’s implementation does none of this. Is Corona doing anything other than calling the server and passing it on to the listener? It does not seem to be. Just turning off the network sets isVerified to false which makes it almost useless by itself.

I see the expiration is included in the callback to the corona listener. I’m guessing I must handle all this on my own. The expiration returned from google play appears to be a timestamp but with extra numbers tacked on the end. I could not decipher from the google documentaion what this format is or if it is just safe to drop the extra numbers. Anyone know?

So anyone with more knowledge on this subject and could share, I would appreciate it.

OK I will ask a much more simple and straight question. If someone at Corona could kindly answer.

The expiration returned from the licensing module is 3 digits longer than the time given by os.time(). Dropping these last 3 digits appears to leave a valid timestamp I can compare to os.time(). However I would like to verify this with Corona Labs. Can I safely drop the last 3 digits of the expiration returned from the licensing module?

The licensing module should actually cache the value for you.  If that is not the case then it is a bug.

The reason why one is 3 digits long is that os.time() returns the unix time in seconds while the value returned from Google’s servers is in milliseconds.  They also say that this value should be “unchanging” so they aren’t going to change the units. (http://developer.android.com/google/play/licensing/licensing-reference.html#VT)  This means that yes, you can ignore those last 3 digits.

Good to know. I wanted to be 100% sure. I have already coded a work around my problems with how it works.

However concerning the intended use and caching. If it is caching, shouldn’t isVerified still be true even though there is a network error (no internet)? It should pass verification at least until expired. As of now it doesn’t and looking at other posts, one I believe even Rob posted into, others are coding around the network error by ignoring the licensing altogether and letting the app be used, if there is a network error. That seems to defeat the purpose of even trying to protect your app with this module.

If there is a network error, the module should check the expiration. If it is not expired it should respond as isVerified until it is.

I tried the following scenario which worked as intended but maybe you tried something else.  If so can you please post the steps to what you did?

  1. Build the licensing sample app with the appropriate key/package name

  2. Install the app and then open it

  3. Press the “Verify” button (Verification was successful)

  4. Close the app and remove it from the recent apps list

  5. Turn off wifi/data network

  6. Open the app again 

  7. Press the “Verify” button( Verification was successful)

It can be so frustrating to not get the expected results. Plugged my app’s information into the test app and still was getting results I was not expecting. However I think I have now confirmed why.

You would expect this to be prominent on the googles site. Even more so on the license testing section itself of googles developer console, but it’s not. Mentioned on one page in troubleshooting I found this tid-bit that made it all make sense. 

Note that the ServerManagedPolicy caches test LICENSED responses for only one minute. Normal (non-test) LICENSED responses will be cached longer.

I guess this is an important note they find unimportant for someone to know when actually testing. I was testing so I was using the “NOT LICENSED” and “LICENSED” settings. Thus only getting a 1 minute license. I guess I am too slow at turning off the wifi and testing again. However using “RESPOND NORMALLY” appears to give a 24 hour license and works as expected.

 I apologize for wasting your time and thank you again!

You’re not the only one who has been frustrated by Google’s Licensing implementation.   :slight_smile:

OK I will ask a much more simple and straight question. If someone at Corona could kindly answer.

The expiration returned from the licensing module is 3 digits longer than the time given by os.time(). Dropping these last 3 digits appears to leave a valid timestamp I can compare to os.time(). However I would like to verify this with Corona Labs. Can I safely drop the last 3 digits of the expiration returned from the licensing module?

The licensing module should actually cache the value for you.  If that is not the case then it is a bug.

The reason why one is 3 digits long is that os.time() returns the unix time in seconds while the value returned from Google’s servers is in milliseconds.  They also say that this value should be “unchanging” so they aren’t going to change the units. (http://developer.android.com/google/play/licensing/licensing-reference.html#VT)  This means that yes, you can ignore those last 3 digits.

Good to know. I wanted to be 100% sure. I have already coded a work around my problems with how it works.

However concerning the intended use and caching. If it is caching, shouldn’t isVerified still be true even though there is a network error (no internet)? It should pass verification at least until expired. As of now it doesn’t and looking at other posts, one I believe even Rob posted into, others are coding around the network error by ignoring the licensing altogether and letting the app be used, if there is a network error. That seems to defeat the purpose of even trying to protect your app with this module.

If there is a network error, the module should check the expiration. If it is not expired it should respond as isVerified until it is.

I tried the following scenario which worked as intended but maybe you tried something else.  If so can you please post the steps to what you did?

  1. Build the licensing sample app with the appropriate key/package name

  2. Install the app and then open it

  3. Press the “Verify” button (Verification was successful)

  4. Close the app and remove it from the recent apps list

  5. Turn off wifi/data network

  6. Open the app again 

  7. Press the “Verify” button( Verification was successful)

It can be so frustrating to not get the expected results. Plugged my app’s information into the test app and still was getting results I was not expecting. However I think I have now confirmed why.

You would expect this to be prominent on the googles site. Even more so on the license testing section itself of googles developer console, but it’s not. Mentioned on one page in troubleshooting I found this tid-bit that made it all make sense. 

Note that the ServerManagedPolicy caches test LICENSED responses for only one minute. Normal (non-test) LICENSED responses will be cached longer.

I guess this is an important note they find unimportant for someone to know when actually testing. I was testing so I was using the “NOT LICENSED” and “LICENSED” settings. Thus only getting a 1 minute license. I guess I am too slow at turning off the wifi and testing again. However using “RESPOND NORMALLY” appears to give a 24 hour license and works as expected.

 I apologize for wasting your time and thank you again!

You’re not the only one who has been frustrated by Google’s Licensing implementation.   :slight_smile: