To use Mobile SDK, add a connection script to the <head> page:
<script src="https://vk.com/js/api/mobile_sdk.js" type="text/javascript"></script>
Then initialize the VK object:
<script type="text/javascript">
VK.init(function() {
// API initialization succeeded
// Your code here
}, function() {
// API initialization failed
// Can reload page here
}, '5.60');
</script>
These methods are used for working with the native interface of mobile apps. Review the Mobile Client API methods list for Javascript and Flash SDK.
Parameters: —
This opens a window to invite user friends to the app. After closing the window, the event
onInviteBoxDone is called with these values passed:
- status (string) — action status: cancel — canceled by user, success — operation successful, fail — operation failed;
- [data (array) — an array of user IDs belong to those who did not receive invites (status = fail).]
Parameters:
user_id (integer),
message (string),
request_key (string)
This opens a window to send user “‘user_id’”, a request with the text “‘message’”. “‘request_key’” is a random string to track conversion (request_key is passed in the app’s launch parameters if the launch was requested). After closing the window, the event “‘onRequestBoxDone’” is called with these values passed:
- status (string) — action status: cancel — canceled by user, success — operation successful, fail — operation failed;
- [data (integer) — error code for status = fail].
Before calling “‘showRequestBox’”, it is necessary to acquire a list of users to whom you can send requests using the API method
friends.getAppUsers.
Parameters:
message (string),
attachments (array),
target (string)
This opens a window for sharing the text “‘message’” and attachments “‘attachments’”.
target =
wall — sharing to the wall,
target =
im — sharing via private messages. A post may have no more than 2 attachments — a photo and a link (if
target =
im, the link needs to be indicated in the message text
message). After closing the window, the event “onShareBoxDone” is called with these values passed:
- status (string) — action status: cancel — canceled by user, success — operation successful, fail — operation failed;
- [data (integer) — error code for status = fail].
Parameters:
settings (integer)
This opens a windows for requesting access rights to the app. The parameters “‘settings’” is a bit mask for requested access rights. If “‘settings’” = ‘“0’”, then the user will be permitted all possible access rights. After closing the window, the event “‘onSettingsBoxDone’” is called with these values passed:
- status (string) — action status: cancel — canceled by user, success — operation successful, fail — operation failed;;
- [data (string) — new access_token].
Parameters:
item (string)
This opens a window for purchasing products in an app. The parameter “‘item’” contains the name of the product that will be sent in payment notifications. After closing the window, the event
onOrderBoxDone is called with these values passed:
- status (string) — action status: cancel — canceled by user, success — operation successful, fail — operation failed;
- [data (integer) — error code for status = fail].
Add payment testers in app settings in the section “Payments”. The accounts of testers should have at least one vote. While spending votes, they are not charged to the testers’ accounts.
This shows a window displaying the app’s tournament standings. The tournament standings may show user progress according to points or level earned (the type of tournament standings is selected in the “Manage app” section). user_result shows the current user’s result.
VK API methods allow working with VK user and community data. To communicate with API methods in Mobile SDK, use the function VK.api. It takes the following parameters:
- methodName (string) — API method name;
- params (object) — Object containing method parameters;
- callback (function) — Function to which the acquired result will be passed after the method is executed.
API method parameters are passed in the sequence «key»: «value».