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:
```java tab=”Android(Java)”
String code = … ; // Promo code to claim
GetSocial.claimPromoCode(code, new Callback
1 2 3 4 5 6 7 8 9 10 |
|
});
kotlin tab=”Android(Kotlin)”
val code: String = … // Promo code to claim
GetSocial.claimPromoCode(code, object : Callback
override fun onSuccess(promoCode: PromoCode) {
println(“Promo Code successfully claimed”)
// Reward user based on promo code info
}
override fun onFailure(exception: GetSocialException) {
println(“Failed to claim Promo Code, error: ${exception.message}”)
}
})
```
```objective-c tab=”iOS(Objective-C)”
NSString *code = … ; // Promo code to claim
[GetSocial claimPromoCode:code
success:^(GetSocialPromoCode *_Nonnull promoCode) {
NSLog(@”Promo Code successfully claimed”);
// Reward user based on promo code info
}
failure:^(NSError *_Nonnull error) {
NSLog(@”Failed to claim Promo Code, error: %@”, error);
}];
```swift tab="iOS(Swift)"
let code: String = ... // Promo code to claim
GetSocial.claimPromoCode(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)")
}
```csharp tab=”Unity”
string code = … ; // Promo code to claim
GetSocial.ClaimPromoCode(code, promoCode =>
{
Debug.Log(“Promo Code claimed successfully”);
// Reward user based on promo code info
}, error =>
{
Debug.Log(“Failed to claim Promo Code, error: ” + error);
});
## 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:
```java tab="Android(Java)"
String code = ... ; // Promo code
GetSocial.getPromoCode(code, new Callback<PromoCode>() {
@Override
public void onSuccess(final PromoCode promoCode) {
Log.d("Promo Code: " + promoCode);
}
@Override
public void onFailure(GetSocialException exception) {
Log.d("Failed to get Promo Code, error: " + exception.getMessage());
}
});
```kotlin tab=”Android(Kotlin)”
val code: String = … // Promo code
GetSocial.getPromoCode(code, object : Callback
override fun onSuccess(promoCode: PromoCode) {
println(“Promo Code: ${promoCode}”)
}
1 2 3 |
|
})
objective-c tab=”iOS(Objective-C)”
NSString *code = … ; // Promo code
[GetSocial getPromoCode:code
success:^(GetSocialPromoCode *_Nonnull promoCode) {
NSLog(@”Promo Code: %@”, promoCode);
}
failure:^(NSError *_Nonnull error) {
NSLog(@”Failed to get Promo Code, error: %@”, error);
}];
```
```swift tab=”iOS(Swift)”
let code: String = … // Promo code
GetSocial.getPromoCode(code, success: { promoCode in
print(“Promo Code: (promoCode)”)
}) { error in
print(“Failed to get Promo Code, error: (error)”)
}
```csharp tab="Unity"
string code = ... ; // Promo code
GetSocial.GetPromoCode(code, promoCode =>
{
Debug.Log("Promo Code: " + promoCode);
}, error =>
{
Debug.Log("Failed to get Promo Code, error: " + error);
});