Claim Promo Code

A user can claim each Promo Code only once. If Promo Code was successfully claimed, you will receive successful callback with all its data. Also you can get the Promo Code info without claiming, if you have only a code. Callback returns an error in case when Promo Code:

  • had been already claimed by current user;
  • is disabled on the Dashboard;
  • is not yet active;
  • is expired;
  • has reached its max claim count.

To claim Promo Code:

1
2
3
4
5
6
7
val code: String = ... // promo code to claim
PromoCodes.claim(code, { result: PromoCode ->
    Log.d("PromoCodes", "Promo code claimed: $result")
    // reward user based on promo code info
}, { error: GetSocialError ->
    Log.d("PromoCodes", "Failed to claim promo code: $error")
})
1
2
3
4
5
6
PromoCodes.claim(code, success: { promoCode in
    print("Promo Code successfully claimed")
    // Reward user based on promo code info
}) { error in
    print("Failed to claim Promo Code, error: \(error)")
}
1
2
3
4
5
6
7
PromoCodes.Claim("code",
    (promoCode) => {
        Debug.Log("Promo Code successfully claimed");
    },
    (error) => {
        Debug.Log("Failed to claim promo code, error: " + error);
});
1
2
3
4
5
PromoCodes.claim('code').then((promoCode) => {
    console.log('Promo Code successfully claimed');
}, (error) => {
    console.log('Failed to claim promo code, error: ' + error.message);
});

Get Promo Code info

You may want to show some Promo Code data to user before claiming it, you can load it with next code:

1
2
3
4
5
6
val code: String = ... // promo code 
PromoCodes.claim(code, { result: PromoCode ->
    Log.d("PromoCodes", "Promo code: $result")
}, { error: GetSocialError ->
    Log.d("PromoCodes", "Failed to get promo code: $error")
})
1
2
3
4
5
PromoCodes.get(code, success: { promoCode in
    print("Promo Code: \(promoCode)")
}) { error in
    print("Failed to get Promo Code, error: \(error)")
}
1
2
3
4
5
6
7
PromoCodes.Get("code",
    (promoCode) => {
        Debug.Log("Promo Code: " + promoCode);
    },
    (error) => {
        Debug.Log("Failed to get promo code, error: " + error);
});
1
2
3
4
5
PromoCodes.get('code').then((promoCode) => {
    console.log('Promo Code: ' + promoCode);
}, (error) => {
    console.log('Failed to get promo code, error: ' + error);
});

Give us your feedback! Was this article helpful?

😀 🙁