SDK integration guide
Step 1: SDK Integration
To enable SDK functionality on your TMA, add the following code to the <head>
section of your page:
This code loads the SDK for integrating advertising functionality.
Step 2: SDK Initialization
After adding the SDK, initialize it to specify who is using it and how it should operate.
This code initializes the TappAds SDK with the provided API key and enables debug mode. After successful initialization, a message is displayed in the console. If there's an error, it will be logged as well.
Parameters:
adv_apikey
: Your API key for SDK usage.debug: true
: Debug mode. Set to false in production to disable debug messages.
Step 3: Fetching the Feed
After initialization, retrieve the feed—a list of tasks available for users on your page.
This code uses the getFeed()
method from the TappAds SDK to obtain the task feed. It returns a Promise handled by .then()
and .catch()
:
If successful, the feed is displayed in the console.
If an error occurs, it’s logged in the console with "Feed error."
This code is part of the SDK integration process and follows the SDK initialization steps.
Example Feed:
The feed is an array of objects, where each object represents a task.
Object Fields:
btn_label
: Button text.name
: Task name.description
: Task description.icon
: Task icon.id
: Unique task identifier.is_done
: Completion flag.payout
: Reward amount.
Step 4: Starting a Task
To start a task, use taskStart
with the task ID.
This code calls the taskStart
method in the TappAds SDK, passing taskId
(task identifier). It returns a Promise handled as follows:
If the task starts successfully, "Task started" with the task ID is logged.
If an error occurs, it’s logged with "Task start error."
Replace taskId
with a real task ID from your feed.
taskId
: ID from the feed.
Step 5: Checking Task Statuses
To check the status of tasks, use getTaskStatus
with an array of task IDs.
This code uses the getTaskStatus
method from the TappAds SDK to check task statuses. It accepts an array of taskIds
(task identifiers) and returns a Promise. The result is handled as follows:
If the statuses are successfully retrieved, they’re logged in the console.
If there’s an error, it’s logged as "Error get statuses."
Replace taskIds
with an actual array of task IDs whose statuses you want to check.
Sample Status Response:
Possible Statuses:
new
: Task created.started
: Task started by the user.completed
: Task completed.
These steps will help you integrate and use the TappAds SDK effectively.
Last updated