Share API
Share API
shareForReward(options)
Executes a reward-based share. The share UI and reward decision are handled by the platform; the SDK only receives the final result.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | - | URL to share |
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
| Field | Type | Description |
|---|---|---|
rewarded | boolean | Whether reward was granted |
errMsg | string | Result message |
TudadaSDK.shareForReward({
url: 'https://example.com/share',
success: (res) => {
if (res.rewarded) {
console.log('Share complete - reward granted');
}
},
fail: (err) => console.error('Share failed:', err.errMsg),
});
shareForRewardAsync(options)
Promise version of reward-based share.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | - | URL to share |
Return Value (Promise<ShareForRewardResult>):
| Field | Type | Description |
|---|---|---|
rewarded | boolean | Whether reward was granted |
const result = await TudadaSDK.shareForRewardAsync();
if (result.rewarded) {
console.log('Share complete - reward granted');
}