Unity SDK allows to deeply integrate Android and iOS applications that are using Unity with OK
Seting up
Before using Unity SDK you need to be sure everything is configured correctly for your app:
iOS or/and Android platform is added to your app’s platforms list;
client authorization is enabled;
redirect_uri okauth://ok{APP_ID} or ok{APP_ID}://authorize (depending on selected platform) is added to redirect_uri’s list;
application has all required API permissions. It is recommended to have LONG_ACCESS_TOKEN and VALUABLE_ACCESS permissions enabled.
Installation
Depending on Unity version (4 or 5) вyou need to copy all required DLL- and meta-files and delete all other files (odnoklassniki_unity4.dll, odnoklassniki_unity4.dll.meta / odnoklassiki_unity5.dll, odnoklassniki_unity5.dll.meta from Assets/Plugins). Make sure that DLL’s GUID is unchangeable, because in case of has been changed enabled prebuffs could be broken. Make sure that this must be done before opening a project in Unity.
Fill application properties in OdnoklassnikiSettings.asset file.
Add following text to android.manifest file:
with application tag
with manifest tag
SDK usage example
Initialisation
Authorization
Two ways to authorize in app via OK are possible at the moment: with installed OK app (Android / iOS) or with WebView.
After authorization process is finished user’s session token can be used for a limited time (30 minutes without LONG_ACCESS_TOKEN permission, 30 days when this permission is enabled):
If authorization was proceeded through official OK application, you will get refresh_token that allows you to get a new access_token for up to 30 days:
To get a working access_token you cab use this code: