JS SDK is supported for:
- all web apps launched on out desktop platform ok.ru;
- all new mobile apps launched on our mobile platform in an iframe (partially)
If your application is still launched as an external page you can request us to launch it in an iframe sending a request to email@example.com
Methods supported on mobile are marked with icon
Methods available ONLY on mobile are marked with icon
Setting up SDK
Connecting a library:
When using js + flash in a flash application, the “wmode=opaque” parameter must be set.
After every transition inside an iframe it is necessary to perform an initialization again with the FAPI.init method, as well as pass the following parameters:
SDK allows you to:
- invoke OK REST API methods;
- implement social mechanics - posts, invites and notifications between users;
- implement in-app purchases and subscriptions;
- implement in-app ads;
- work with browser window and iframe in which app is launched.
- FAPI.init - SDK initialization. Must be called before calling any method (both when launching applications for the first time and when doing internal transitions across the frame).
- FAPI.UI.showPayment - dialog for buying game currency or game items;
- FAPI.invokeUIMethod(“showPaymentSubscription”) - dialog for purchasing an in-game subscription.
- FAPI.invokeUIMethod(“prepareMidroll”) - prepare a video ad to show during game session;
- FAPI.invokeUIMethod(“showMidroll”) - shows a video ad previously prepared during game session.
Working with REST API
- FAPI.UI.showPermissions - dialog for requesting permissions (e.g. to change the user status);
- FAPI.Client.call - calling API methods with automated signature calculation.
- FAPI.Util.getRequestParameters - getting parameters when addressing the application;
- FAPI.UI.getPageInfo - information about the page (height, width, scrolling position, position of the application iframe);
- FAPI.UI.changeHistory - changes current URL on Odnoklassniki for user;
- FAPI.UI.scrollTo - scrolls the page to a specific position;
- FAPI.UI.scrollToTop - scrolls the page to the top;
- FAPI.UI.setWindowSize - changing the size of application container;
- FAPI.invokeUIMethod(“requestFullscreen”) - opens game iframe in a fullscreen mode;
- FAPI.invokeUIMethod(“showHideLocation”) - shows a hint to hide browser’s navigation bar.
Methods from the FAPI.UI group don’t require the callback function to be passed. After the method is executed, a global function will be called, and the developer must realize it. The function must have the signature:
- method - the name of the method called
- result - the result of the execution (“ok” if successful, “cancel” if the user canceled the action)
- data - additional information, for example, for showInvite() – a list of IDs of invited friends, separated by commas, in the string format.