Other methods
There are some other methods in the adjoe SDK which you might find helpful.
name
description
getVersion
Returns the internal version code of the adjoe SDK, for example 17.
getVersionName
Returns the version name of the adjoe SDK, for example 1.2.0.
hasAcceptedTOS
Returns true if the user has accepted the adjoe TOS and false otherwise.
hasAcceptedUsagePermission
Returns true if the user has granted access to the app usage statistics and the adjoe SDK was initialized accordingly, false otherwise. Note that this method will always return true on devices with an Android API level smaller than 21.

Payout via SDK

The following information on SDK-side reward handling is only relevant for your integration if you cannot use Server-to-Server Payout. Do not implement these functions if you already successfully followed the steps in the Payout section - it could trigger error messages and unexpected behaviour.
If you cannot handle the payout requests via an endpoint on your server, we can also handle the reward payouts inside the SDK itself.
To pay out the rewards that the user has collected from partner apps directly in the SDK, call
1
adjoe.doPayout()
2
.then((payoutValue) => {
3
// successfully paid out 'payoutValue' rewards
4
})
5
.catch((reason, err) => {
6
// an error occurred while paying out the rewards
7
8
// 'reason' is one of
9
// - Adjoe.PAYOUT_UNKNOWN
10
// - Adjoe.PAYOUT_NOT_ENOUGH_COINS
11
// - Adjoe.PAYOUT_TOS_NOT_ACCEPTED
12
13
// if available, get more information about the error
14
console.error(err);
15
});
Copied!
This method always pays out all rewards which the user has collected, i.e. the value of rewards.available_payout_coins.
If the user has not accepted the adjoe Terms of Service yet, this operation will fail and reason will be equal to Adjoe.PAYOUT_TOS_NOT_ACCEPTED. You might want to display the offerwall again so that the user can accept the adjoe Terms of Service. This operation will also fail with reason equal to Adjoe.PAYOUT_UNKNOWN if the user is blocked by the adjoe services.

Adjoe Parameters

You can pass additional UA and placement parameters when you pay out the rewards:
1
Adjoe.doPayout({
2
'uaNetwork': "uaNetwork_value",
3
'uaChannel': "uaChannel_value",
4
'uaSubPublisherCleartext': "uaSubPublisherCleartext_value",
5
'uaSubPublisherEncrypted': "uaSubPublisherEncrypted_value",
6
'placement': 'placement_value'
7
});
Copied!

Retrying the payout

Sometimes, it can happen that the latest rewards haven't been processed yet by the server when you pay out. In this case, the promise rejects with reason equal to Adjoe.PAYOUT_NOT_ENOUGH_COINS. To overcome this, you can implement a retry mechanism for the payout, for example with an exponential backoff.
Example:
1
const PAYOUT_RETRY_BASE = 2000;
2
const PAYOUT_RETRY_MULTIPLIER = 2;
3
const MAX_PAYOUT_RETRIES = 5;
4
5
const doAdjoePayout = () => {
6
doAdjoePayoutInternal(0);
7
};
8
9
const doAdjoePayoutInternal = (times) => {
10
if (times < 0 || times >== MAX_PAYOUT_RETRIES) {
11
// the payout has failed too often, which means that the user has no coins
12
// you should handle this case properly
13
return;
14
}
15
16
Adjoe.doPayout()
17
.then((payoutValue) => {
18
// everything is fine, rewards have been paid out
19
})
20
.catch((reason, err) => {
21
if (reason === Adjoe.PAYOUT_NOT_ENOUGH_COINS) {
22
setTimeout(() => {
23
doAdjoePayoutInternal(times + 1);
24
}, PAYOUT_RETRY_BASE * PAYOUT_RETRY_MULTIPLIER^times);
25
} else {
26
console.log(err);
27
}
28
});
29
};
Copied!

Further context on Rewards

You can get information about the rewards that the user has collected as well as about how many rewards are available for payout and how many the user has already spent.
To do so call
1
Adjoe.requestRewards()
2
.then((rewards) => {
3
// successfully requested the rewards
4
5
// get how many rewards the user has collected
6
const reward = rewards.reward;
7
8
// get how many rewards are available for payout
9
const availableForPayout = rewards.available_for_payout;
10
11
// get how many rewards the user has already spent
12
const alreadySpentCoins = rewards.already_spent;
13
})
14
.catch((err) => {
15
// an error occurred while requesting the rewards
16
// you can try to get additional information about the error for debugging
17
console.error(err);
18
});
Copied!
This operation will fail if the SDK is not initialized, the user has not accepted the adjoe Terms of Service or is blocked by the adjoe services.

Adjoe Parameters

You can pass additional UA and placement parameters when you request the rewards:
1
Adjoe.requestRewards({
2
'uaNetwork': "uaNetwork_value",
3
'uaChannel': "uaChannel_value",
4
'uaSubPublisherCleartext': "uaSubPublisherCleartext_value",
5
'uaSubPublisherEncrypted': "uaSubPublisherEncrypted_value",
6
'placement': 'placement_value'
7
});
Copied!
Last modified 24d ago