Type Library Revision Release 2024.3703 Keywords VK, Vkontakte, VK Direct, VK Direct Games Platforms HTML5
The VK Direct Games plugin, simple wrapper for VK Mobile. For more information please, refer to Mobile Client API documentation
Note, that APIs would actually work only when app is ran as VK Direct Game on mobile device. To learn more about how to create and deploy your applications see Direct Games documentation.
local vk = require("plugin_vk_direct")
vk.init(function)
Initializes the plugin and sets event listener to handle events from VK APIs. Event structure is described in the following section.
vk.api(methodName, params)
This method call would trigger VK.api(methodName, params)
and invoke event name with method
set to methodName
.
All following functions are wrappers around Mobile SDK methods with same name. Please, refer to documentation for details.
vk.showInviteBox()
vk.showRequestBox(user_id, message, request_key)
vk.showSettingsBox(settings)
vk.showOrderBox(type, item)
vk.showLeaderboardBox(user_result)
This methods are aliases for VK.callMethod(methodName, {arguments})
. Result would be dispatched to event listener with method
field set to the function name.
Each API call would result in event sent to listener passed to vk.init()
. All events have similar 3 fields:
event.name
String. Always "vk"
.
event.method
String containing name of the method callback is invoked for. For example "init"
or "showInviteBox"
. Note that this would have different value in vk.api()
callback.
event.status
String containing "success"
or "failure"
depending on call results.
event.data
Table containing call results if applicable.
To use this plugin, add an entry into the plugins
table of build.settings
. When added, the build server will integrate the plugin during the build phase.
settings = { plugins = { ["plugin.vk.direct"] = { publisherId = "com.coronalabs" }, }, }
local loadingText = display.newText( "Loading...", display.contentCenterX, display.contentCenterY, nil, 20) local vk = require("plugin_vk_direct") local function vkListener( event ) if event.method == "init" then if event.status == "success" then composer.gotoScene( "menu" ) loadingText:removeSelf( ) else loadingText.text = "VK Initialization error" end end end vk.init(vkListener)