Sign in

SCILLClient

Use this class to initiate the client side API.

Constructor

Initiate an instance of the SCILLClient class with the access token previously generated in the backend or in safe environments with the SCILLBackend class instance.

Use the getters to get a shared instance of the API classes. SCILLClient sets them up correctly for production use and with the correct authentication system.

Please note: You can implement the backend in any programming language you like, for example with NodeJS you can implement the backend side with a couple of lines of code.

public SCILLClient(string accessToken, string appId);
Parameters

accessToken string

You need to provide an access token that you previously generated with the EventsApi. Please check out the documentation about access tokens for more info.

appId string

This is the app id of your application. Use the Admin Panel to reveal the app id for your application.

EventsApi (Getter)

Returns a shared, lazy loaded instance of the EventsApi. It’s used to send events required for challenges and battle passes.

public EventsApi EventsApi;

ChallengesApi (Getter)

Returns a shared, lazy loaded instance of the ChallengesApi. It’s used to handle challenges.

static ChallengesApi ChallengesApi;

BattlePassesApi (Getter)

Returns a shared, lazy loaded instance of the BattlePassesApi. It’s used to handle battle passes.

static BattlePassesApi BattlePassesApi;

StartChallengeUpdateNotifications

Connects to SCILLs MQTT server and forwards incoming payloads to the provided handler function.

public void StartChallengeUpdateNotifications(ChallengeChangedNotificationHandler handler)
Parameters

handler ChallengeChangedNotificationHandler

Provide a handler function that is called whenever new payloads are sent from the SCILL backend. The function is defined like this:

public delegate void ChallengeChangedNotificationHandler(ChallengeWebhookPayload payload);
Warning

The payload is called from a worker thread to prevent blocking the main thread. However, as MQTT updates often have direct implication on the user interface make sure, that your User Interface supports updates from worker thread. Unity, for example does not support that, and you need to make sure, that you dispatch changes to the user interface in a way that it works with Unity. Please have a look in our Unity example code to understand how to do that.

StopChallengeUpdateNotifications

Disconnects from the MQTT server and stops receiving notifications.

public void StopChallengeUpdateNotifications(ChallengeChangedNotificationHandler handler)

StartBattlePassUpdateNotifications

Connects to SCILLs MQTT server and forwards incoming payloads to the provided handler function.

public void StartBattlePassUpdateNotifications(string battlePassId, BattlePassChangedNotificationHandler handler)
Parameters

battlePassId ChallengeChangedNotificationHandler

Provide the battle pass id. This is the same as the battle_pass_id property in the BattlePass object.

handler BattlePassChangedNotificationHandler

Provide a handler function that is called whenever new payloads are sent from the SCILL backend. The function is defined like this:

public delegate void BattlePassChangedNotificationHandler(BattlePassChallengeChangedPayload payload);
Warning

The payload is called from a worker thread to prevent blocking the main thread. However, as MQTT updates often have direct implication on the user interface make sure, that your User Interface supports updates from worker thread. Unity, for example does not support that, and you need to make sure, that you dispatch changes to the user interface in a way that it works with Unity. Please have a look in our Unity example code to understand how to do that.

StopChallengeUpdateNotifications

Disconnects from the MQTT server and stops receiving notifications.

public void StopChallengeUpdateNotifications(ChallengeChangedNotificationHandler handler)

GenerateAccessToken

public AccessToken|Error GenerateAccessToken(ForeignUserIdentifier body);
Parameters

body ForeignUserIdentifier

Foreign user identifier.

Returns

In case of a success, this function returns an instance of AccessToken. In case of a failure, this function returns an instance of Error or Error or .

GetUserChallengeNotificationTopic

public NotificationTopic|Error GetUserChallengeNotificationTopic(string challenge_id);

Get a topic to be used with an MQTT client to receive real time updates whenever the challenge changes.

Parameters

challenge_id string

The challenge id you want to get notified

Returns

In case of a success, this function returns an instance of NotificationTopic. In case of a failure, this function returns an instance of Error or Error.

GetUserChallengesNotificationTopic

public NotificationTopic|Error GetUserChallengesNotificationTopic();

Get a topic to be used with an MQTT client to receive real time updates whenever challenges for the user provided by the access token change.

Returns

In case of a success, this function returns an instance of NotificationTopic. In case of a failure, this function returns an instance of Error or Error.

GetUserBattlePassNotificationTopic

public NotificationTopic|Error GetUserBattlePassNotificationTopic(string battle_pass_id);

Get a topic to be used with an MQTT client to receive real time updates whenever a battle pass changes.

Parameters

battle_pass_id string

The battle pass you want to get notified

Returns

In case of a success, this function returns an instance of NotificationTopic. In case of a failure, this function returns an instance of Error or Error.

SendEvent

public ActionResponse|UnknownChallengeError SendEvent(EventPayload body);

Post an event to the SCILL backend

Parameters

body EventPayload

Event payload

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of or UnknownChallengeError.

GetAvailableEvents

public EventDescription[] GetAvailableEvents();

Get all available events and required and optional properties

Returns

In case of a success, this function returns an instance of EventDescription[]. In case of a failure, this function returns an instance of .

GetPersonalChallenges

public ChallengeCategory[]|Error GetPersonalChallenges();

Get personal challenges organized in categories

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of ChallengeCategory[]. In case of a failure, this function returns an instance of Error or Error.

GetPersonalChallengeById

public Challenge|Error GetPersonalChallengeById(string challengeId);

Get personal challenges organized in categories

Parameters

appId string

The app id

challengeId string

The challenge id (see challenge_id of Challenge object)

Returns

In case of a success, this function returns an instance of Challenge. In case of a failure, this function returns an instance of Error or Error.

GetActivePersonalChallenges

public ChallengeCategory[]|Error GetActivePersonalChallenges();

Get active personal challenges organized in categories

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of ChallengeCategory[]. In case of a failure, this function returns an instance of Error or Error.

UnlockPersonalChallenge

public ActionResponse|Error UnlockPersonalChallenge(string challengeId);

Unlock a personal challenge by product id and challenge id

Parameters

appId string

The app id

challengeId string

The challenge id (see challenge_id of Challenge object)

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

ActivatePersonalChallenge

public ActionResponse|Error ActivatePersonalChallenge(string challengeId);

Activate a personal challenge by product id and user challenge id

Parameters

appId string

The app id

challengeId string

The challenge id (see challenge_id of Challenge object)

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

CancelPersonalChallenge

public ActionResponse|Error CancelPersonalChallenge(string challengeId);

Cancel an active personal challenge by product id and user challenge id

Parameters

appId string

The app id

challengeId string

The challenge id (see challenge_id of Challenge object)

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

ClaimPersonalChallengeReward

public ActionResponse|Error ClaimPersonalChallengeReward(string challengeId);

Claim the reward of a finished personal challenge by product id and user challenge id

Parameters

appId string

The app id

challengeId string

The challenge id (see challenge_id of Challenge object)

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

GenerateWebsocketAccessToken

public SocketToken|Error GenerateWebsocketAccessToken();

Get an access token for the Websockets server notifying of updates in real time

Returns

In case of a success, this function returns an instance of SocketToken. In case of a failure, this function returns an instance of Error or Error.

GetBattlePasses

public BattlePass[]|Error GetBattlePasses();

Get battle passes for the product

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of BattlePass[]. In case of a failure, this function returns an instance of Error or Error.

GetActiveBattlePasses

public BattlePass[]|Error GetActiveBattlePasses();

Get active battle passes for the app

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of BattlePass[]. In case of a failure, this function returns an instance of Error or Error.

GetUnlockedBattlePasses

public BattlePass[]|Error GetUnlockedBattlePasses();

Get unlocked battle passes for the user encoded in the access token

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of BattlePass[]. In case of a failure, this function returns an instance of Error or Error.

GetBattlePass

public BattlePass|Error GetBattlePass(string battlePassId);

Get battle pass for the product with id

Parameters

appId string

The app id

battlePassId string

The id of the battle pass. It’s the same as in battle_pass_id you received in earlier requests (i.e. getting all active battle passes for a product).

Returns

In case of a success, this function returns an instance of BattlePass. In case of a failure, this function returns an instance of Error or Error.

GetBattlePassLevels

public BattlePassLevel[]|Error GetBattlePassLevels(string battlePassId);

Get battle pass levels for a battle pass

Parameters

appId string

The app id

battlePassId string

The id of the battle pass. It’s the same as in battle_pass_id you received in earlier requests (i.e. getting all active battle passes for a product).

Returns

In case of a success, this function returns an instance of BattlePassLevel[]. In case of a failure, this function returns an instance of Error or Error.

GetAllBattlePassLevels

public BattlePassLevel[]|Error GetAllBattlePassLevels();

Get all battle pass levels for an app

Parameters

appId string

The app id

Returns

In case of a success, this function returns an instance of BattlePassLevel[]. In case of a failure, this function returns an instance of Error or Error.

ActivateBattlePassLevel

public ActionResponse|Error ActivateBattlePassLevel(string levelId);

Activate a given battle pass level by id

Parameters

appId string

The app id

levelId string

The id of the battle pass level.

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

ClaimBattlePassLevelReward

public ActionResponse|Error ClaimBattlePassLevelReward(string levelId);

Claim the battle pass level id

Parameters

appId string

The app id

levelId string

The id of the battle pass level.

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an instance of Error or Error.

UnlockBattlePass

public BattlePassUnlockInfo|Error UnlockBattlePass(string battlePassId);

Unlock the battle pass for a user

Parameters

appId string

The app id

battlePassId string

The id of the battle pass. It’s the same as in battle_pass_id you received in earlier requests (i.e. getting all active battle passes for a product).

Returns

In case of a success, this function returns an instance of BattlePassUnlockInfo. In case of a failure, this function returns an instance of Error or Error or Error.