1.0.36 • Published 2 years ago

fapiv2clienttest v1.0.36

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Odnoklassniki app sdk

Usage

import OKSDK from '@odnoklassniki/apps-sdk';

// Init SDK
OKSDK.init();

For use in a browser, include the file dist/browser.min.js and use as follows

<script src="https://unpkg.com/@ok/apps-sdk/dist/browser.min.js"></script>

<script>
    // Init SDK
    OKSDK.init();
</script>

API Reference

OKSDK.Methods

Contains groups of methods that avalable and recommended for use

Some of them return promise with response

Response fields

  • status Text with status ok | error
  • data Data of response string | boolean | number | object

Example

const {status, data: appId} = await OKSDK.Methods.Utils.getAppId();

Some of them return value synchronously

Example

const isSupported = OKSDK.Methods.Utils.isSupported(); // boolean

Some of them need callback to be provided

Callback arguments

  • status Text with status ok | error
  • data Data of response string | boolean | number | object

Example

const callback = (status, data) => {
    console.log(data);
};

OKSDK.Methods.Utils.observeServiceCallbacks('DEVICE_ORIENTATION', callback);

OKSDK.invoke

OKSDK.invokeUIMethod @Depricated

This methods allow you to call methods as it was done in previous versions of SDK

Parameters

  • method required Method name
  • params optional Array of parameters
  • callback optional Callback for getting result

Example

// Sending event to client
OKSDK.invoke('joinGroup', [groupId], ({status, data}) => {});

OKSDK.Client.call

Call API methods

Parameters

  • params required Object with call params including method name
  • callback required A function that will be called after the server responds
  • resig optional Required when it is necessary to request user confirmation for any action through a separate preview. In all other cases, call the function with only 2 parameters.

Example

// Sending event to client
const params = {
    "method":"friends.get"
};

const callback = (status, data, error) => {
    if (error) {
        processError(error);
    } else {
        processFriendIds(data);
    }
};

OKSDK.Client.call(params, callback);
1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago