Create Promo Code¶
You can create Promo Codes on the Dashboard or using the SDK.
Create on Dashboard¶
To create a Promo Code from our Dashboard, follow the steps below:
- Login into the GetSocial Dashboard.
- Click on Create new code from the sidebar menu or from the Promo Codes section.
- (Optional) Specify a code or leave the field empty to let the Dashboard generate a 5-chars code for you.
- (Optional) Define a time period during which the code can be claimed.
- (Optional) Limit the amount of times that the code can be claimed.
- (Optional) Include key-value pairs to the code with extra information. This custom data will be available when the code is claimed.
- Click Create.
Create on SDK¶
To create new Promo Code use createPromoCode
method:
```java tab=”Android(Java)”
GetSocial.createPromoCode(PromoCodeBuilder.createRandomCode(), new Callback
@Override
public void onSuccess(final PromoCode result) {
Log.d(“GetSocial”, “Promo Code successfully created: ” + result.getCode());
}
1 2 3 4 |
|
})
kotlin tab=”Android(Kotlin)”
GetSocial.createPromoCode(PromoCodeBuilder.createRandomCode(), object : Callback
override fun onSuccess(promoCode: PromoCode) {
println(“Promo Code successfully created: ${promoCode.code}”)
}
override fun onFailure(exception: GetSocialException) {
println(“Failed to create Promo Code, error: ${exception.message}”)
}
})
```
```objective-c tab=”iOS(Objective-C)”
[GetSocial createPromoCode:[GetSocialPromoCodeBuilder withRandomCode]
success:^(GetSocialPromoCode *_Nonnull promoCode) {
NSLog(@”Promo code successfully created: %@”, promoCode.code);
}
failure:^(NSError *_Nonnull error) {
NSLog(@”Failed to create Promo Code, error: %@”, error);
}];
```swift tab="iOS(Swift)"
GetSocial.createPromoCode(GetSocialPromoCodeBuilder.withRandomCode(), success: { promoCode in
print("Promo Code successfully created: \(promoCode.code)")
}) { error in
print("Failed to create Promo Code, error: \(error)")
}
```csharp tab=”Unity”
GetSocial.CreatePromoCode(PromoCodeBuilder.WithRandomCode(), promoCode =>
{
Debug.Log(“Promo Code created successfully: ” + promoCode.Code);
}, error =>
{
Debug.Log(“Failed to create Promo Code, error: ” + error);
});
You can create Promo Code with randomly generated code(5 symbols) or provide a code.
### Create with random code
To create a Promo Code with random code:
```java tab="Android(Java)"
PromoCodeBuilder promoCode = PromoCodeBuilder.createRandomCode();
```kotlin tab=”Android(Kotlin)”
val promoCode = PromoCodeBuilder.createRandomCode()
```objective-c tab="iOS(Objective-C)"
GetSocialPromoCodeBuilder *promoCode = [GetSocialPromoCodeBuilder withRandomCode];
```swift tab=”iOS(Swift)”
let promoCode = GetSocialPromoCodeBuilder.withRandomCode()
```csharp tab="Unity"
var promoCode = PromoCodeBuilder.CreateRandomCode();
Create with provided code¶
Promo codes can contain only numbers, small and big letters. The length of code should not be more than 16 symbols. To create Promo Code:
```java tab=”Android(Java)”
String code = … ; // your code
PromoCodeBuilder promoCode = PromoCodeBuilder.createWithCode(code);
```kotlin tab="Android(Kotlin)"
val code : String = ... // your code
val promoCode = PromoCodeBuilder.createWithCode(code)
```objective-c tab=”iOS(Objective-C)”
NSString *code = … ; // your code
GetSocialPromoCodeBuilder *promoCode = [GetSocialPromoCodeBuilder withCode:code];
```swift tab="iOS(Swift)"
let code: String = ... // your code
let promoCode = GetSocialPromoCodeBuilder.withCode(code)
```csharp tab=”Unity”
string code = … ; // your code
var promoCode = PromoCodeBuilder.CreateCode(code);
### Setup promo code limitations
For now you can set next limitations:
- Time span when promo code is active.
- Maximum claim count for all users.
#### Time limitations
By default Promo Code is active from the moment of creation and forever(unless you [disable it manually on the Dashboard](#)). To set time limits:
```java tab="Android(Java)"
Date startDate = ... ; // when promo code should start being active
Date endDate = ... ; // when promo code should stop beign active
PromoCodeBuilder promoCode = PromoCodeBuilder.createRandomCode()
.withTimeLimit(startDate, endDate);
```kotlin tab=”Android(Kotlin)”
val startDate : Date = … // when promo code should start being active
val endDate : Date = … // when promo code should stop beign active
val promoCode = PromoCodeBuilder.createRandomCode()
.withTimeLimit(startDate, endDate)
```objective-c tab="iOS(Objective-C)"
NSDate *startDate = ... ; // when promo code should start being active
NSDate *endDate = ... ; // when promo code should stop beign active
GetSocialPromoCodeBuilder *promoCode = [GetSocialPromoCodeBuilder withRandomCode];
[promoCode setTimeLimitWithStartDate:startDate endDate:endDate];
```swift tab=”iOS(Swift)”
let startDate: Date = … // when promo code should start being active
let endDate: Date = … // when promo code should stop beign active
let promoCode = GetSocialPromoCodeBuilder.withRandomCode()
promoCode.setTimeLimitWithStart(startDate, end: endDate)
```csharp tab="Unity"
DateTime startDate = ... ; // when promo code should start being active
DateTime endDate = ... ; // when promo code should stop beign active
var promoCode = PromoCodeBuilder.CreateRandomCode()
.WithTimeLimit(startDate, endDate);
Max claims count¶
If you want to limit the number of users who can claim Promo Code, you can use max claim count. If it is set to some number n
, only first n
users can successfully claim the code, all next attempts will result in error. By default max claim count is 0
which means there is no limit. To set max claim count:
```java tab=”Android(Java)”
int maxClaimCount = … ; // your limitation
PromoCodeBuilder promoCode = PromoCodeBuilder.createRandomCode()
.withMaxClaimCount(maxClaimCount);
```kotlin tab="Android(Kotlin)"
val maxClaimCount : Int = ... // your limitation
val promoCode = PromoCodeBuilder.createRandomCode()
.withMaxClaimCount(maxClaimCount)
```objective-c tab=”iOS(Objective-C)”
uint maxClaimCount = … ; // your limitation
GetSocialPromoCodeBuilder *promoCode = [GetSocialPromoCodeBuilder withRandomCode];
[promoCode setMaxClaimCount:maxClaimCount];
```swift tab="iOS(Swift)"
let maxClaimCount: uint = ... // your limitation
let promoCode = GetSocialPromoCodeBuilder.withRandomCode()
promoCode.setMaxClaimCount(maxClaimCount)
```csharp tab=”Unity”
uint maxClaimCount = … ; // your limitation
var promoCode = PromoCodeBuilder.CreateRandomCode()
.WithMaxClaimCount(maxClaimCount);
### Attach custom data
You can attach key-value pairs of strings to Promo Code and get them later to have more details which promotions or referrals it holds.
```java tab="Android(Java)"
Map<String, String> customData = ... ;
PromoCodeBuilder promoCode = PromoCodeBuilder.createRandomCode()
.addData("key", "value") // you can attach single pair
.addData(customData); // or entire map
```kotlin tab=”Android(Kotlin)”
val customData : Map
val promoCode = PromoCodeBuilder.createRandomCode()
.addData(“key”, “value”) // you can attach single pair
.addData(customData) // or entire map
```objective-c tab="iOS(Objective-C)"
GetSocialPromoCodeBuilder *promoCode = [GetSocialPromoCodeBuilder withRandomCode];
[promoCode addDataValue:@"value" forKey:@"key"]; // you can attach single pair
[promoCode addData:@{ @"key1", @"value1" }]; // or entire map
```swift tab=”iOS(Swift)”
let promoCode = GetSocialPromoCodeBuilder.withRandomCode()
promoCode.addDataValue(“value”, forKey: “key”) // you can attach single pair
promoCode.addData([“key1” : “value1”]) // or entire map
```csharp tab="Unity"
Dictionary<string, string> customData = ... ;
var promoCode = PromoCodeBuilder.CreateRandomCode()
.AddData("key", "value") // you can attach single pair
.AddData(customData); // or entire dictionary