Jump to: navigation, search

Framework API Design

System Introduction

AnySDK Framework classifies existing third party SDKs into six systems: user system, payment system, ad system, statistics system, social system and sharing system.

User system API: login, logout, switch account, platform center, display floating button, hide floating button, display exit page, display pause page and other channel related features.

Payment system API: payment, acquire order number.

Analytics system API: start conversation, end conversation, set conversation duration, turn on/off catching exceptions, exception information report, custom events and other statistic related features.

Sharing system API: sharing.

Ad system API: display ad, hide ad.

Social system API: submit score, display ranking list, unlock achievements, display achievement list.

Principles of API Calling

AnySDK Framework encapsulates a third party SDK (jar lib) with a layer of simple C++ APIs.

Necessary Steps to Integrate

1. Build AnySDK Framework’s environment and import its necessary files; please refer to AnySDK Framework development environment building.
2. Initialize plugin; refer to initializing.
3. After initializing, set listening class immediately and listen to the callback message; refer to message notice.
4. User System
4.1 For calling method of extendable API, please refer to extendable features introduction.
4.2 Call login when capturing the notice of initialization accomplished; refer to login, logout.
4.3 Call floating button when entering the game and call hide floating button at pause.
4.4 Call pause page API when the game pauses or resumes; refer to display pause page.
4.5 Call exit page API when exiting the game; refer exit page API.
4.6 The app needs an obvious API of the platform center; refer to entering platform center.
4.7 The app needs to have switch account API integrated; refer to entering platform center.
4.8 Call destroy API when uninstalling the game.

Message Notice

Mainly used for notifying users about the result of an asynchronous request; each system has set message notice respectively and users only need to implement abstract method listener and set listener class to catch request result. Example of calling method: override callback method.

class PluginChannel:public PayResultListener, public UserActionListener
	virtual void onPayResult(PayResultCode ret, const char* msg, TProductInfo info);
	virtual void onActionResult(ProtocolUser* pPlugin, UserActionResultCode code, const char* msg);

Set listener class:

_pluginsIAPMap  = AgentManager::getInstance()->getIAPPlugin();
    std::map<std::string , ProtocolIAP*>::iterator iter;
    for(iter = _pluginsIAPMap->begin(); iter != _pluginsIAPMap->end(); iter++)


AnySDK takes care of integrating all the third party SDKs to make it easy for developers. Core features can be called directly. Extended features from plug-ins can be called with extented methods after they are determined to be existing. AnySDK handles this by allowing the developer to check to see if the desited functionality exists. To call an extended function, the plug-in needs to be determined to be existing.Also,For features that are special to a particular third party SDK, you must check that the function is supported before calling it. Here is an example of checking if a function is supported:

        return AgentManager::getInstance()->getUserPlugin()->isSupportFunction(strClassName);

AnySDK Framework provides extended methods as below:

void callFuncWithParam(const char* funcName, PluginParam* param, ...) ;
void callFuncWithParam(const char* funcName, std::vector<PluginParam*> params);
std::string callStringFuncWithParam(const char* funcName, PluginParam* param, ...) ;
std::string callStringFuncWithParam(const char* funcName, std::vector<PluginParam*> params);

int callIntFuncWithParam(const char* funcName, PluginParam* param, ...) ;
int callIntFuncWithParam(const char* funcName, std::vector<PluginParam*> params);

bool callBoolFuncWithParam(const char* funcName, PluginParam* param, ...);
bool callBoolFuncWithParam(const char* funcName, std::vector<PluginParam*> params);

float callFloatFuncWithParam(const char* funcName, PluginParam* param, ...);
float callFloatFuncWithParam(const char* funcName, std::vector<PluginParam*> params) ;

When calling an extended function with parameters, you need wrap each parameter into a PluginParam type. For example:void showToolBar(ToolBarPlace place)

PluginParam paramInfo(kToolBarTopRightMid);

Test Mode

Test mode allows developers to finish development process without integrating to any channel. It simulates the channel SDK and accomplishes the login, logout and payment API of the channel SDK.

When testing with a Sample project, you need to test with a public test account.

Developer account: ID: demo@anysdk.com;Password:123456 Test account: ID:demo Password: demo Accounts should only be used for the original package.

Add Test Account

Add atest account to the backend of dev.anysdk.com and add corresponding test coins.

Use Test Account

The generated test account can be used to accomplish the login, logout and payment feature of AnySDK framework.

Other APIs

With other APIs, AnySDK framework too has provided a simple interface or Log to let you know when it’s called successfully.