Unity Challenges SDK

Dashboard Integration

The Monetizr Dashboard requires a registration process in order to acquire an API key for the challenges. The API Key is used to connect with the challenges API. The challenges at this point are created for each game separately and added for your account. Challenges will be included in dashboard in the near future.

SDK Integration

Installation

To use Challenges SDK download the Unity package from GitHub and import monetizr_challenges_unity_sdk_1.0.unitypackage into your project using Assets/Import Package/Custom Package....

Detailed SDK description and source code is available at the repository.

Using

The challenges Unity SDK at this moment is a proof-of-concept solution. The challenges SDK utilizes the challenges API endpoints. The SDK is not a fit-for-everyone as it will likely require customization and minor adjusting for most of the games.

You will need to to create and use one instance of ChallengesClient class and use it to communicate with the Monetizr Challenges API. You also will need to set the current user's information in ChallengesClient.playerInfo (at least the identifier) to use the SDK. Challenge list can be retrieved using GetList . Whenever a progress is being made by player, UpdateChallenge has to be called. When the challenge is done, a claim button must be shown in the challenge menu and ClaimChallenge must be called whenever player clicks on the claim.

Reference

Monetizr.Challenges namespace

ChallengesClient class

Constructor(string apiKey, int timeout = 30) – creates an instance of ChallengesClient and sets the API key used by the SDK to apiKey
GetList() – acquires a list of challenges available to the player
GetSingle(string id) – acquires a single challenge identified by its id
UpdateStatus(Challenge challenge, int progress, Action onSuccess, Action onFailure) – update the player's progress for a specific challenge
ClaimChallenge(Challenge challenge, Action onSuccess, Action onFailure) – has to be invoed when a player clicks the claim button on a completed challenge
playerInfo – used to get and set player's information

AssetsHelper

Download2DAsset(Challenge.Asset asset, Action<Challenge.Asset, Sprite> onAssetDownloaded) – downloads a 2D asset and returns it as a Sprite in onAssetDownloaded callback.

DownloadAssetData(Challenge.Asset asset, Action<Challenge.Asset, byte[]> onAssetDownloaded) – Downloads any type of asset and returns its data as an array of bytes in onAssetDownloadedCallback.

PlayerInfo class

location – location of the current user (the location is used for challenges that are targeted for a specific region, for challenges without regional targeting is not being used)
age – age of the current user (used for challenges that are age specific, for challenges without age without age restrictions is not being used)
gameType – type of the game (used for challenges that are targeted for a specific game types)
playerId – a unique identifier of the user (mandatory)

Challenge class

id – identification number of the challenge (has to be passed to UpdateChallenge and ClaimChallenge)
title – title of the challenge (has to be visible in the challenge menu).
content – description of the challenge (has to be visible in the challenge menu).
progress – players progress (has to be visible in the challenges menu).
reward – type of reward when the challenge is completed (created for each game individually according to their requirements and agreement).
assets – a list of assets of the challenge (see Challenge.Asset).

Challenge.Asset class

id – identification number of the asset (can be ignored)
type – type of the asset (icon or banner)
title – name of the asset (can be ignored)
url – the location of the asset


Did this page help you?