It’s really easy to add an extra layer of protection when submitting your Google Play apps. Take a look:
http://www.develephant.net/using-google-licensing-to-protect-your-corona-sdk-app/
Cheers.
It’s really easy to add an extra layer of protection when submitting your Google Play apps. Take a look:
http://www.develephant.net/using-google-licensing-to-protect-your-corona-sdk-app/
Cheers.
Bravo!
Rob
I used this approach, to be a bit more relaxed in case the user didn’t have internet connectivity when they try to use the app - not sure if this the best idea or not…
local device = require("lib.device") if not device.isSimulator and device.isAndroid then -- Listener local licensingListener = function(event) if event and (not event.isError) and (not event.isVerified) then -- Show Error Message then QUIT native.showAlert( "Error", "License Invalid.\n".. "Download from Google Play Store.", {"OK"}, function(event) native.requestExit() end ); else -- Allow user to use app (e.g. for any time there is an "error" with the request) end end -- Call Google local licensing = require("licensing"); licensing.init("google"); licensing.verify(licensingListener); end
I have a similar approach to greg. However I specifically test for network errors.
local networkError = (event.errorType == “network”)
I don’t want users to get a “pirate” message just because they have Airplane mode active. The caveat is that the users who know about it can just turn off network connectivity / wifi to access the app. But I think it’s the price I have to pay to avoid legitimate users from getting false alarms.
Great tips everyone. I did touch upon the simulator “bypass” setting in the midst of some paragraph or another, but I will go in and update it with more additional info and detail.
Really appreciate the feedback.
Cheers.
Bravo!
Rob
I used this approach, to be a bit more relaxed in case the user didn’t have internet connectivity when they try to use the app - not sure if this the best idea or not…
local device = require("lib.device") if not device.isSimulator and device.isAndroid then -- Listener local licensingListener = function(event) if event and (not event.isError) and (not event.isVerified) then -- Show Error Message then QUIT native.showAlert( "Error", "License Invalid.\n".. "Download from Google Play Store.", {"OK"}, function(event) native.requestExit() end ); else -- Allow user to use app (e.g. for any time there is an "error" with the request) end end -- Call Google local licensing = require("licensing"); licensing.init("google"); licensing.verify(licensingListener); end
I have a similar approach to greg. However I specifically test for network errors.
local networkError = (event.errorType == “network”)
I don’t want users to get a “pirate” message just because they have Airplane mode active. The caveat is that the users who know about it can just turn off network connectivity / wifi to access the app. But I think it’s the price I have to pay to avoid legitimate users from getting false alarms.
Great tips everyone. I did touch upon the simulator “bypass” setting in the midst of some paragraph or another, but I will go in and update it with more additional info and detail.
Really appreciate the feedback.
Cheers.
Great material. Don’t know how I missed it when first posted. Thanks to Alex as well for including it in his weekly blog entry.
Hi -
I am having problems with the google store initializing my license.
I am getting this error:
Google Play
“Failed to initialize Licensing Service!”
OK
I think I followed everyones code - seems like it should work: I am using Version 2013.1260 (2013.11.13) because of graphic and other changes. Any suggestions?
[lua]
Main:
local licensing = require( “licensing” )
local gInit = licensing.init( “google” )
local function ExitApp()
native.requestExit() --assuming this is how we handle pirates
end
local function licensingListener( event )
if not event.isVerified then
if gInit == false then
native.showAlert(“Google Play------”,“Failed to initialize Licensing Service!”,{“OK”})
end
--failed verify app from the play store, we print a message
– native.showAlert("Google Play- what is up ",“Google Play was unable to verify the license for this app. The app will now close.”,{“OK”}, ExitApp)
end
end
licensing.verify( licensingListener )
config: (tried it with and without policy )
application =
{
content =
{
width = 1600, --1280,
height = 2048, --2360, --2048,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = .1,
},
},
license = {
google = {
key = “my key”
,policy = “serverManaged”,
},
},
}
Build:
settings =
{
orientation =
{
default = “landscapeRight”,
supported = { “landscapeLeft”, “landscapeRight” }
},
android =
{
versionCode = “4”,
– usesExpansionFile = true,
usesPermissions =
{
“android.permission.INTERNET”,
“com.android.vending.CHECK_LICENSE”,
– “com.android.vending.BILLING”,
“android.permission.RECORD_AUDIO”,
“android.permission.WRITE_EXTERNAL_STORAGE”,
},
},
}
[/lua]
Can’t say that I ever had this issue. I don’t know if you can set the licensing init call to a variable, and if the false is really accurate. Wonder if that is causing the issue?
You can try checking event.response or event.errorType to see if those give you a clue.
I will try printing out the event.response and event.errortype and not using a variable to check.
On the simulator I am getting the message below but it is allowing me to go on. Is that unusual?
WARNING: The ‘licensing’ provider (google) is not available on the simulator
WARNING: The ‘licensing’ library is not available on this platform.
Licensing only runs on Android devices. You cannot test it on the Simulator.
As well, you must make sure that the Google account on the testing device is listed in the Google Play Developer Console for testing licensing and that you set the response correctly.
Hi,
Just looking into this Licensing thing myself.
Don’t quote me here as i am a newbie - Line 14 does not have the oncomplete ExitApp - that you have commented out in line 18.
Have yet to test on device (takes a bit of time) but have simmed it on the simulator to see the process
–local licensing = require “licensing”
–licensing.init( “google” )
–local function licensingListener( event )
local function licensingListener()
– local verified = event.isVerified
verified = false
if verified then
– if event.isVerified then
Seems to work - or at least confirms the code flow.
T.
Great material. Don’t know how I missed it when first posted. Thanks to Alex as well for including it in his weekly blog entry.
Hi -
I am having problems with the google store initializing my license.
I am getting this error:
Google Play
“Failed to initialize Licensing Service!”
OK
I think I followed everyones code - seems like it should work: I am using Version 2013.1260 (2013.11.13) because of graphic and other changes. Any suggestions?
[lua]
Main:
local licensing = require( “licensing” )
local gInit = licensing.init( “google” )
local function ExitApp()
native.requestExit() --assuming this is how we handle pirates
end
local function licensingListener( event )
if not event.isVerified then
if gInit == false then
native.showAlert(“Google Play------”,“Failed to initialize Licensing Service!”,{“OK”})
end
--failed verify app from the play store, we print a message
– native.showAlert("Google Play- what is up ",“Google Play was unable to verify the license for this app. The app will now close.”,{“OK”}, ExitApp)
end
end
licensing.verify( licensingListener )
config: (tried it with and without policy )
application =
{
content =
{
width = 1600, --1280,
height = 2048, --2360, --2048,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = .1,
},
},
license = {
google = {
key = “my key”
,policy = “serverManaged”,
},
},
}
Build:
settings =
{
orientation =
{
default = “landscapeRight”,
supported = { “landscapeLeft”, “landscapeRight” }
},
android =
{
versionCode = “4”,
– usesExpansionFile = true,
usesPermissions =
{
“android.permission.INTERNET”,
“com.android.vending.CHECK_LICENSE”,
– “com.android.vending.BILLING”,
“android.permission.RECORD_AUDIO”,
“android.permission.WRITE_EXTERNAL_STORAGE”,
},
},
}
[/lua]