Type CoronaLibrary Revision Release 2022.3683 Keywords license, licensing
The Solar2D licensing library lets you check to see if the app was bought from a store. Currently, only Google Play is supported.
For further information, see the Google licensing reference page.
You must add the following permission to your build.settings
file in order to use the Google licensing provider:
settings = { android = { usesPermissions = { "com.android.vending.CHECK_LICENSE" }, }, }
In addition, you must include the license
table with your unique license key within the project's config.lua
file. This key value must be obtained from Google.
application = { license = { google = { key = "YOUR_LICENSE_KEY", policy = "serverManaged" }, }, }
The policy
key is optional. Its value can be either "serverManaged"
(default) or "strict"
. A value of "serverManaged"
will query the Google server and cache the results; this is similar to Google's ServerManagedPolicy. A value of "strict"
will not cache the results, so when there's a network failure, the licensing will fail; this is similar to Google's StrictPolicy.
local licensing = require( "licensing" ) local function licensingListener( event ) if not ( event.isVerified ) then -- Failed to verify app from the Google Play store; print a message print( "Pirates!!!" ) end end local licensingInit = licensing.init( "google" ) if ( licensingInit == true ) then licensing.verify( licensingListener ) end