Шукати в цьому блозі

googlelicensing -апі ліцензії

googlelicensing

Спадковість:  

Підтримувані платформи:


Available since version:  

Опис:

інтегрування сервіса ліцензій гугллплея

Приклади:

Синтаксис: Lua
require "googlelicensing"

googlelicensing:setKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlanL9lpyJbFyQ1TcxxIXxo13SZCxgXEVSedfOOXfI6XZF1r/zUu9gsyIsgytSCzKt8IKwAZhU9hPteLhJsYhXj0hXorC+hgWcmd3LUeDQkxqPUQdVzdEKE0g4m0AshQoiVsJmgejxQCZzhc6wsLss0EgmXXYjndr53OrGK3sil7KSvrLonm7CdGChTFqECpGazQEW+ru5lzbI1MEqU1KsGg31DyvPeh27Xsbk9I6I6Ff/2LvEfMZa//0LVJwJmS0p+Z/LUUnv3Qi+V5KopOMx1pkqXY3EL9SAdaPABAkr2j2Ic8L5YtDaMqhwjZtp7As/9EmMFlwo765/9RTHf8fCwIDAQAB")--ваш відкритий ключ

local text = TextField.new(nil, "Тач по екрану щоб перевірити ліцензію")
text:setScale(2)
text:setPosition(10, 100)
stage:addChild(text)

googlelicensing:addEventListener(Event.LICENSE_ALLOWED, function()
        AlertDialog.new("Насолоджуйтесь грою", "Ви можете грати, гра пройшла верифікацію ", "Ok"):show()
end)

googlelicensing:addEventListener(Event.LICENSE_DENIED, function()
        AlertDialog.new("Купити гру", "Вам потрібно придбати гру щоб грати", "Cancel", "Buy"):show()
end)

googlelicensing:addEventListener(Event.LICENSE_RETRY, function()
        AlertDialog.new("Please retry", "Ми не можемо підтвердити вашу ліцензію зараз, спробуйте пізніше.", "Ok"):show()
end)

googlelicensing:addEventListener(Event.DOWNLOAD_REQUIRED, function()
        AlertDialog.new("Need download", "Потрібно завантажити деякі файли", "Ok"):show()
end)

googlelicensing:addEventListener(Event.DOWNLOAD_NOT_REQUIRED, function()
        AlertDialog.new("Enjoy the game", "Все добре, можете грати", "Ok"):show()
end)

googlelicensing:addEventListener(Event.DOWNLOAD_STATE, function(e)
        print(e.state, e.message, "Ok")
end)

googlelicensing:addEventListener(Event.DOWNLOAD_PROGRESS, function(e)
        print("Download progress", e.speed, e.timeLeft, e.progress, e.total)
end)

googlelicensing:addEventListener(Event.ERROR, function(e)
        AlertDialog.new("Error", e.error, "Ok"):show()
end)

text:addEventListener(Event.TOUCHES_BEGIN, function()
        print("started checking")
        --googlelicensing:checkLicense() -- check for license
        googlelicensing:checkExpansion() -- переврка лізензії додатка
        --googlelicensing:cellularDownload(true)
end)

Методи, евенти та властивості:


Методи

  • googlelicensing:setKey("your-public-key") -- set your public key
  • googlelicensing:checkLicense() -- check license of your app
  • googlelicensing:checkExpansion() -- check if expansions files need to be download (will attempt to download them if needed)
  • googlelicensing:cellularDownload(allow) -- pass through to allow downloading files on cellular network, otherwise download will start only on when WIFI is available

Події

  • Event.LICENSE_ALLOWED --license is ok
  • Event.LICENSE_DENIED --license is not ok
  • Event.LICENSE_RETRY --can't check license now, no internet connection or server unreachable
  • Event.DOWNLOAD_REQUIRED --download is required and will try to start automatically
  • Event.DOWNLOAD_NOT_REQUIRED -- all files are here, no download required
  • Event.DOWNLOAD_STATE --event for download state changed:
    • e.state --contains state string
    • e.message --contains state explanatory message
  • Event.DOWNLOAD_PROGRESS --event with download state update
    • e.speed --contains download speed in KB/s
    • e.timeLeft --contains estimated time left for download
    • e.progress --contains amount of downloaded bytes
    • e.total --contains total amount of bytes needed for download
  • Event.ERROR --there was some error checking the license (mostly developer error due to incorrect set up)

Немає коментарів:

Дописати коментар