Managing Reward

The Reward Points Service allows Game Developers to assign rewards to users which the users can redeem whenever they want. For instance, one can give 10 gold reward points on completion of a certain game event to the user. Once user has got the reward points he can redeem it further for other goods.

To get started with rewards, you have to first create rewards inside the AppHQ console and here are the steps to do so.

bullet Login to AppHQ console

bullet Go to Gaming bullet Reward

bullet Click on Add Reward button as shown in below image and fill all the required fields and submit to save the reward

AddRewardLayout

After creating a Reward you can manage your rewards by using the following API calls from your app.

1. Earn Reward

Once a reward is created, you can add reward points to a users account. Reward Points can be earned by the user which can be redeemed later. It requires game name, reward name, user name and reward points to be passed as input parameters.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
BigDecimal rewardPoints = new BigDecimal(3500);
rewardService.earnRewards(gameName,userName,rewardName,rewardPoints, new App42CallBack() {
public void onSuccess(Object response) 
{
	Reward reward  = (Reward)response;
	System.out.println("reward Name is " + reward.getName());  
	System.out.println("reward userName is " + reward.getUserName());  
	System.out.println("reward points is " + reward.getPoints());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
}); 
NSString *gameName = @"<Enter_your_game_name>";
NSString *userName = @"Nick";
NSString *rewardName = @"<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward *reward = [rewardService earnRewards:gameName gameUserName:userName gameScore:gameScore]; 
NSLog(@"rewardName is= %@" reward.gameName);
NSString *jsonResponse = [reward toString]; 
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
rewardService.EarnRewards(gameName,userName,rewardName,rewardPoints,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Reward reward = (Reward) response;     
		Console.WriteLine("rewardName is" + reward.GetName()); 
		Console.WriteLine("gameName is" + reward.GetGameName()); 
		Console.WriteLine("points is" + reward.GetPoints()); 
	}  
}
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward reward = rewardService.earnRewards(gameName,userName,rewardName,rewardPoints); 
System.out.println("rewardName is" + reward.getName()); 
System.out.println("gameName is" + reward.getGameName()); 
System.out.println("points is" + reward.getPoints()); 
var gameName = "gameName",
var rewardName = "<Enter_your_reward_name>",
userName = "Nick",
rewardPoints = 3500,
result ;  
rewardService.earnRewards(gameName,userName,rewardName,rewardPoints,{  
success: function(object) {  
var rewardObj = JSON.parse(object);  
console.log("gameName is" +rewardObj.app42.response.rewards.reward.gameName)
console.log("rewardName is" +rewardObj.app42.response.rewards.reward.name)
console.log("points is" +rewardObj.app42.response.rewards.reward.points)
console.log("userName is" +rewardObj.app42.response.rewards.reward.userName)
},  
error: function(error) {  
}  
}); 
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
BigDecimal rewardPoints = new BigDecimal(3500);
Reward reward = rewardService.earnRewards(gameName,userName,rewardName,rewardPoints); 
System.out.println("rewardName is" + reward.getName()); 
System.out.println("gameName is" + reward.getGameName()); 
System.out.println("points is" + reward.getPoints()); 
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
rewardService.EarnRewards(gameName, userName, rewardName, rewardPoints, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Reward reward = (Reward) response;     
		App42Log.Console("rewardName is" + reward.GetName()); 
		App42Log.Console("gameName is" + reward.GetGameName()); 
		App42Log.Console("points is" + reward.GetPoints());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward reward = rewardService.EarnRewards(gameName,userName,rewardName,rewardPoints); 
Console.WriteLine("rewardName is" + reward.GetName()); 
Console.WriteLine("gameName is" + reward.GetGameName()); 
Console.WriteLine("points is" + reward.GetPoints()); 
$gameName = "<Enter_your_game_name>";
$userName = "Nick";
$rewardName = "<Enter_your_reward_name>";
$rewardPoints = 3500;
$reward = $rewardService->earnRewards($gameName,$userName,$rewardName,$rewardPoints);
print_r("rewardName is" . $reward->getName());
print_r("gameName is" . $reward->getGameName());
print_r("points is" . $reward->getPoints());
$jsonResponse = $reward->toString(); 
game_name = "<Enter_your_game_name>";
game_user_name = "Nick";
reward_name = "<Enter_your_reward_name>";
reward_points = 1000;						
reward = rewardService.earn_rewards(game_name, game_user_name, reward_name, reward_points); 
puts "rewardName is #{reward.name}";
puts "rewardgameName is #{reward.game_name}";
puts "rewarduserName is #{reward.user_name}";
puts "rewardpoints  #{reward.points}";
json_response = reward.to_s();
var gameName:String = "<Enter_your_game_name>";
var userName:String = "userName";
var rewardName:String = "<Enter_your_reward_name>";
var rewardPoints:int = 100;
rewardService.getRewardByName(gameName,userName,rewardName,rewardPoints,new callback());  
public class callback implements App42CallBack  
{ 
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var reward:Reward = Reward(response);
		trace("rewardName is" + reward.getName()); 
		trace("gameName is" + reward.getGameName()); 
		trace("points is" + reward.getPoints());  
	}  
}
Coming Soon 

2. Redeem Reward

User can redeem his earned rewards for a particular game. Once reward is redeemed it will be deducted from his total rewards. It requires game name, reward name, user name and reward points to be passed as input parameters.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
BigDecimal rewardPoints = new BigDecimal(3500);
rewardService.redeemRewards(gameName,userName,rewardName,rewardPoints, new App42CallBack() {
public void onSuccess(Object response) 
{
	Reward reward  = (Reward)response;
	System.out.println("reward Name is " + reward.getName());  
	System.out.println("reward userName is " + reward.getUserName());  
	System.out.println("reward points is " + reward.getPoints());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
}); 
NSString *gameName = @"<Enter_your_game_name>";
NSString *userName = @"Nick";
NSString *rewardName = @"<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward *reward = [rewardService redeemRewards:gameName gameUserName:userName gameScore:gameScore]; 
NSLog(@"rewardName is= %@" reward.gameName);
NSString *jsonResponse = [reward toString]; 
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
rewardService.RedeemRewards(gameName,userName,rewardName,rewardPoints,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Reward reward = (Reward) response;     
		Console.WriteLine("rewardName is" + reward.GetName()); 
		Console.WriteLine("gameName is" + reward.GetGameName()); 
		Console.WriteLine("points is" + reward.GetPoints()); 
	}  
}
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward reward = rewardService.redeemRewards(gameName,userName,rewardName,rewardPoints); 
System.out.println("rewardName is" + reward.getName()); 
System.out.println("gameName is" + reward.getGameName()); 
System.out.println("points is" + reward.getPoints()); 
var gameName = "gameName",
var rewardName = "<Enter_your_reward_name>",
userName = "Nick",
rewardPoints = 3500,
result ;  
rewardService.redeemRewards(gameName,userName,rewardName,rewardPoints,{  
success: function(object) {  
var rewardObj = JSON.parse(object);  
console.log("gameName is" +rewardObj.app42.response.rewards.reward.gameName)
console.log("rewardName is" +rewardObj.app42.response.rewards.reward.name)
console.log("points is" +rewardObj.app42.response.rewards.reward.points)
console.log("userName is" +rewardObj.app42.response.rewards.reward.userName)
},  
error: function(error) {  
}  
}); 
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
BigDecimal rewardPoints = new BigDecimal(3500);
Reward reward = rewardService.redeemRewards(gameName,userName,rewardName,rewardPoints); 
System.out.println("rewardName is" + reward.getName()); 
System.out.println("gameName is" + reward.getGameName()); 
System.out.println("points is" + reward.getPoints()); 
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
rewardService.RedeemRewards(gameName, userName, rewardName, rewardPoints, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Reward reward = (Reward) response;     
		App42Log.Console("rewardName is" + reward.GetName()); 
		App42Log.Console("gameName is" + reward.GetGameName()); 
		App42Log.Console("points is" + reward.GetPoints());
	}

	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game_name>";
String userName = "Nick";
String rewardName = "<Enter_your_reward_name>";
double rewardPoints = 3500;
Reward reward = rewardService.RedeemRewards(gameName,userName,rewardName,rewardPoints); 
Console.WriteLine("rewardName is" + reward.GetName()); 
Console.WriteLine("gameName is" + reward.GetGameName()); 
Console.WriteLine("points is" + reward.GetPoints()); 
$gameName = "<Enter_your_game_name>";
$userName = "Nick";
$rewardName = "<Enter_your_reward_name>";
$rewardPoints = 3500;
$reward = $rewardService->redeemRewards($gameName,$userName,$rewardName,$rewardPoints);
print_r("rewardName is" . $reward->getName());
print_r("gameName is" . $reward->getGameName());
print_r("points is" . $reward->getPoints());
$jsonResponse = $reward->toString(); 
game_name = "<Enter_your_game_name>";
game_user_name = "Nick";
reward_name = "<Enter_your_reward_name>";
reward_points = 1000;						
reward = rewardService.redeem_rewards(game_name, game_user_name, reward_name, reward_points); 
puts "rewardName is #{reward.name}";
puts "rewardgameName is #{reward.game_name}";
puts "rewarduserName is #{reward.user_name}";
puts "rewardpoints  #{reward.points}";
json_response = reward.to_s();
var gameName:String = "<Enter_your_game_name>";
var userName:String = "userName";
var rewardName:String = "<Enter_your_reward_name>";
var rewardPoints:int = 100;
rewardService.redeemRewards(gameName,userName,rewardName,rewardPoints,new callback());  
public class callback implements App42CallBack  
{ 
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var reward:Reward = Reward(response);
		trace("rewardName is" + reward.getName()); 
		trace("gameName is" + reward.getGameName()); 
		trace("points is" + reward.getPoints());  
	}  
}
Coming Soon 

3. Fetching User Reward

You can fetch the list of all rewards earned by an individual user. This requires user name and reward name to be passed as input as shown in the below snippet.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
rewardService.getAllRewardsByUser(userName,rewardName, new App42CallBack() {
public void onSuccess(Object response) 
{
	ArrayList<Reward> reward = (ArrayList<Reward>)response;
	for(int i = 0;i < reward.size();i++)
	{
		System.out.println("rewardName is : " + reward.get(i).getName());
		System.out.println("gameName is : " + reward.get(i).getGameName());
		System.out.println("point is : " + reward.get(i).getPoints());
		System.out.println("userName : " + reward.get(i).getUserName());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
NSString *rewardName = @"<Enter_your_reward_name>";
NSString *userName  = @"Nick";
NSArray *reward = [rewardService getAllRewardsByUser:userName rewardName:rewardName]; 
NSLog(@"rewardName is %@" , [[reward objectAtIndex:0] name]);
NSLog(@"rewardDescription is %@" ,  [[reward objectAtIndex:0] description]);
NSString *jsonResponse =[[reward objectAtIndex:0] toString]; 
public class Callback : App42Callback  
{  
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
rewardService.GetAllRewardsByUser(userName,rewardName,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		IList<Reward> reward = (List<Reward>) response;  
		for(int i = 0;i < reward.size();i++)
		{
			Console.WriteLine("rewardName is " + reward[i].GetName());
			Console.WriteLine("rewardDescription is " + reward[i].GetDescription());
		}
	}  
}  
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
Vector reward = rewardService.getAllRewardsByUser(userName,rewardName); 
for(int i=0;i < rewardList.size();i++)
{ 
	Reward reward = (Reward)  rewardList.elementAt(i);
	System.out.println("rewardName is : " + reward.getName());
	System.out.println("gameName is : " + reward.getGameName());
	System.out.println("point is : " + reward.getPoints());
}
var rewardName = "<Enter_your_reward_name>",
userName  = "Nick",
result ;  
rewardService.getAllRewardsByUser(userName,rewardName,{  
	success: function(object)
	{  
		var rewardObj = JSON.parse(object);  
		result = rewardObj.app42.response.rewards.reward;
		for(var i = 0;i<result.length;i++)
		{
			console.log("rewardName is " + result[i].name)
			console.log("gameName is " + result[i].gameName)
			console.log("point is " + result[i].points)
		}
	},  
	error: function(error) {  
	}  
});     
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
ArrayList<Reward> reward = rewardService.getAllRewardsByUser(userName,rewardName); 
for(int i = 0;i < reward.size();i++)
{
	System.out.println("rewardName is : " + reward.get(i).getName());
	System.out.println("gameName is : " + reward.get(i).getGameName());
	System.out.println("point is : " + reward.get(i).getPoints());
}
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
rewardService.GetAllRewardsByUser(userName,rewardName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		IList<Reward> reward = (List<Reward>) response;   
		for(int i = 0;i < reward.Count;i++)
		{
			App42Log.Console("rewardName is " + reward[i].GetName()); 
			App42Log.Console("gameName is" + reward[i].GetGameName());
			App42Log.Console("point is : " + reward[i].GetPoints());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String rewardName = "<Enter_your_reward_name>";
String userName  = "Nick";
IList<Reward> reward = rewardService.GetAllRewardsByUser(userName,rewardName); 
for(int i = 0;i < reward.Count;i++)
{
	Console.WriteLine("rewardName is " + reward[i].GetName()); 
	Console.WriteLine("gameName is" + reward[i].GetGameName());
	Console.WriteLine("point is : " + reward[i].GetPoints());
}    
$rewardName = "<Enter_your_reward_name>";
$userName  = "Nick";
$reward = $rewardService->getAllRewardsByUser($userName,$rewardName); 
print_r("rewardName is " . $reward[0]->getName());
print_r("rewardDescription is " . $reward[0]->getDescription());
$jsonResponse = $reward[0]->toString(); 
Coming Soon
var gameName:String = "<Enter_your_game_name>";
var userName:String = "userName";
rewardService.getAllRewardsByUser(gameName,userName,new callback());  
public class callback implements App42CallBack  
{ 
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		if(response is Array)
		{
			for(var i:int = 0;i < response.length;i++)
			{
				var rewards:Reward = Reward(response[i]);
				trace("rewardName : " + rewards.getName());
				trace("gameName : " + rewards.getGameName());
				trace("userName : " + rewards.getUserName());
				trace("points : " + rewards.getPoints());
			}
		}
	}  
}
Coming Soon

4. More Details?

bullet Go To Reward Management API Usage Guide