Introduction
Welcome to the GameSparks Request API!
We have language bindings in C#, C++, Java, ActionScript, Objective-C and also cloud code running in the platform!
You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Initialisation
GS.Initialise(new PlatformBase());
//In C# the platform object is responsible for getting the key & secret
//The unity implementation uses PlatformBase. For other platforms, you can implement your own IGSPlatform
//In unity this code is not required, the GameSparksUnity object deals with this for you.
//In C++ the platform object is responsible for getting the key & secret
MarmaladePlatform* gsPlatform = new MarmaladePlatform(apiKey, secret, usePreviewServer);
// OR
Cocos2dxPlatform* gsPlatform = new Cocos2dxPlatform(apikey, secret, true, true)
...
GS.Initialise(&gsPlatform);
//In Unreal the GameSparks Component object is responsible for getting the key and secret
GameSparksComponent->Connect(key, secret,true);
...
GS.Initialise(&gsPlatform);
GS gs = new GS("<apiKey>", "<apiSecret>", false, new AndroidPlatform());
//Different Platforms are available for other java runtimes
gs.start();
var gs:GS = new GS();
gs.setApiKey("<apiKey>")
.setApiSecret("<apiSecret>")
.setUseLiveServices(false)
.connect();
GS* gs = [[GS alloc] initWithApiKey:apiKey andApiSecret:secret andPreviewMode:true];
Before using the SDK, you need to initialise it with 3 parameters :
- apiKey - This is the unique identifier of your game. This can be found within the configurator on the overview page.
- apiSecret - This is the authentication secret of your game. This can be found within the configurator on the overview page.
- live/preview - This determines whether your SDK is connecting to the live or preview GameSparks servers.
Lifecycle Callbacks
GS.GameSparksAvailable = (available) => {
if(available) {
//SDK is connected
} else {
//SDK is disconnected
}
}
...
GS.GameSparksAuthenticated = (playerId) => {
//playerId is the authenticated players id
};
void GameSparksAvailable(GS& gsInstance, bool available)
{
if(available) {
//SDK is connected
} else {
//SDK is disconnected
}
}
void GameSparksAuthenticated(GS& gsInstance, const gsstl::string& playerId)
{
//playerId is the authenticated players id
}
...
GS.GameSparksAvailable = GameSparksAvailable;
GS.GameSparksAuthenticated = GameSparksAuthenticated;
gs.setOnAvailable(new GSEventConsumer<Boolean>() {
public void onEvent(Boolean available) {
if(available){
//SDK is connected
} else {
//SDK is not connected
}
}
});
gs.setOnAuthenticated(new GSEventConsumer<String>() {
public void onEvent(String playerId) {
//playerId is the authenticated players id
}
});
gs.setAvailabilityCallback(function (available : Boolean):void {
if(available){
//SDK is connected
} else {
//SDK is disconnected
}
});
...
gs.setAuthenticatedCallback(function (playerId : String):void {
//playerId is the authenticated players id
});
[gs setAvailabilityListener:^ (BOOL available) {
success = true;
if(available){
//SDK is connected
} else {
//SDK is disconnected
}
}];
[gs setAuthenticatedListener:^(NSString * userId) {
//playerId is the authenticated players id
}];
A number of callbacks are available when the SDK changes state:
- Available - Called with a boolean parameter when the SDK changes state. The boolean parameter indicates whether the SDK is available
- Authenticated - Called with a string parameter when the SDK becomes authenticated as a player. The string parameter is the playerId of the authenticated player.
These callbacks need to be registered against the SDK. It’s recommended to do this before you initialise the SDK to ensure events are not missed by your code.
Durable Requests
//Mark the request as durable before send is called
request.SetDurable(true);
...
//Iterate the requests in the durable queue and determine if they have a callback.
//In this example, we remove items with a callback, and apply a callback to ones that don't.
//This is not a real world example, but shows the options you have.
GS.DurableQueueLoaded = () => {
foreach (GSRequest durableRequest in GS.DurableQueueEntries) {
if(!durableRequest.HasCallbacks()) {
durableRequest.SetCallback ((data) => {
//Reattached callback
});
} else {
GS.RemoveDurableQueueEntry(durableRequest);
}
}
};
//Mark the request as durable before send is called
request.SetDurable(true);
...
//Iterate the requests in the durable queue and determine if they have a callback.
//In this example, we remove items with a callback, and apply a callback to ones that don't.
//This is not a real world example, but shows the options you have.
gs.OnPersistentQueueLoadedCallback = [&](GS& gs){
for(auto& request : gs.GetDurableQueueEntries()){
if(request.HasCallbacks()) {
gs.RemoveDurableQueueEntry(req);
} else {
request.SetCallback([&](GS& gs, const GSData& data){
//Re-attached callback
});
}
}
};
//Mark the request as durable before send is called
[request setDurable:true];
...
//Iterate the requests in the durable queue and determine if they have a callback.
//In this example, we remove items with a callback, and apply a callback to ones that don't.
//This is not a real world example, but shows the options you have
[gs setAuthenticatedListener:^(NSString * userId) {
[[gs getDurableQueue ] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if([obj hasCallback]){
[gs removeFromDurableQueue:obj];
} else {
[obj setCallback:^ (GSAuthenticationResponse* response) {
success = true;
}];
}
}];
}];
//Mark the request as durable before send is called
request.setDurable(true);
If you mark a request as being durable, it will be queued by the SDK until it can be sent. The SDK’s maintin a list of durable requests for each player, and each list is persisted to disk to ensure any previous durable request will be sent once that player is authenticated.
Currently, durable requests are only available for C#, C++, Obj-C & Java SDK’s.
Once a durable queue is loaded from storage, it will not have a callback attached to it. You have the ability to iterate the durable queue and re-attach callbacks if required.
Extending API Requests
Writing scriptData to a request
GSData scriptData = new GSRequestData ()
.AddNumber ("myNumber", 10)
.AddString ("myString", "the value");
request.SetScriptData (scriptData);
GSRequestData scriptData;
scriptData.AddNumber("myNumber", 10);
scriptData.AddString("myString", "the value");
request.SetScriptData(scriptData);
NSMutableDictionary* scriptData = [[NSMutableDictionary alloc] init];
[scriptData setObject:[NSNumber numberWithInt:10] forKey:@"myNumber"];
[scriptData setObject:@"the value" forKey:@"myString"];
[request setScriptData:scriptData];
Map<String,Object> scriptData = new HashMap<>();
scriptData.put("myNumber", 10);
scriptData.put("myString", "the value");
request.setScriptData(scriptData);
var scriptData:GSData = new GSData()
.setAttribute("myNumber", 10)
.setAttribute("myString", "the value")
request.setScriptData(scriptData);
request.scriptData = {"myNumber" : 10, "myString" : "the value"};
Reading scriptData from a response (or message)
long myNumber = response.ScriptData.GetNumber ("myNumber");
string myString = response.ScriptData.GetString ("myString");
GSData scriptData = response.GetScriptData().GetValue();
long myNumber = scriptData.GetNumber("myNumber").GetValue();
gsstl::string myString = scriptData.GetString("myString").GetValue();
NSNumber* myNumber = [[response getScriptData] objectForKey:@"myNumber"];
NSString* myString = [[response getScriptData] objectForKey:@"myString"];
Long myNumber = (Long) response.getScriptData().getAttribute("myNumber");
String myString = (String) response.getScriptData().getAttribute("myString");
var myNumber:Number = response.getScriptData()["myNumber"];
var myString:String = response.getScriptData()["myString"];
var myNumber = response.scriptData.myNumber;
var myString = response.scriptData.myString;
All API objects are extensible using a optional attribute named “scriptData”. This is a dictionary that you as a developer can use to attach additional data to the requests via the client SDK. This attribute can also be populated using cloude code which can then be read with the SDK.
Asynchronous Messages
The GameSparks platform sends out asynchronous messages to the SDK, this is one of the (many) benefits of using a socket based comunication protocol over using old fashioned REST & polling techniques.
You have the ability to configure your own listener for each message type, examples can be found further down in this manual here
Admin
BatchAdminRequest
{
"@class" : ".BatchAdminRequest",
"playerIds" : [ "" ],
"request" : { }
}
{
"@class" : ".BatchAdminResponse",
"responses" : { },
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new BatchAdminRequest()
.SetPlayerIds(playerIds)
.SetRequest(request)
.Send((response) => {
GSData responses = response.Responses;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createBatchAdminRequest()
.setPlayerIds(playerIds)
.setRequest(request)
.send(function(response:com.gamesparks.api.responses.BatchAdminResponse):void {
var responses:Object = response.getResponses();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSBatchAdminRequest* request = [[GSBatchAdminRequest alloc] init];
[request setPlayerIds:playerIds;
[request setRequest:request;
[request setCallback:^ (GSBatchAdminResponse* response) {
NSDictionary* responses = [response getResponses];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void BatchAdminRequest_Response(GS& gsInstance, const BatchAdminResponse& response) {
GSData responses = response.getResponses();
GSData scriptData = response.getScriptData();
}
......
BatchAdminRequest request(gsInstance);
request.SetPlayerIds(playerIds)
request.SetRequest(request)
request.Send(BatchAdminRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.BatchAdminRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BatchAdminResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createBatchAdminRequest()
.setPlayerIds(playerIds)
.setRequest(request)
.send(new GSEventListener<BatchAdminResponse>() {
@Override
public void onEvent(BatchAdminResponse response) {
GSData responses = response.getResponses();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.BatchAdminRequest();
request.playerIds = ...;
request.request = ...;
var response = request.Send();
var responses = response.responses;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createBatchAdminRequest();
request.setPlayerIds(...);
request.setRequest(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var responses = response.responses;
var scriptData = response.scriptData;
});
Performs a request for multiple players.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
playerIds | Yes | string[] | The players to run the request for. |
request | Yes | DBObject | The request to be run for each player. |
Response Parameters
A response containing the individual responses for requests performed via a BatchAdminRequest
Parameter | Type | Description |
---|---|---|
responses | JSON | A map of responses by player ID |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
playerIds | INVALID | Between 1-500 player IDs must be supplied in the form of an array |
request | INVALID | You must supply a valid request in JSON format to be performed for each player listed in playerIds |
CancelBulkJobAdminRequest
{
"@class" : ".CancelBulkJobAdminRequest",
"bulkJobIds" : [ "" ]
}
{
"@class" : ".CancelBulkJobAdminResponse",
"bulkJobs" : [ {
"actualCount" : 0,
"completed" : "2018-07-11T14:02Z",
"created" : "2018-07-11T14:02Z",
"data" : { },
"doneCount" : 0,
"errorCount" : 0,
"estimatedCount" : 0,
"id" : "",
"moduleShortCode" : "",
"playerQuery" : { },
"scheduledTime" : "2018-07-11T14:02Z",
"script" : "",
"started" : "2018-07-11T14:02Z",
"state" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new CancelBulkJobAdminRequest()
.SetBulkJobIds(bulkJobIds)
.Send((response) => {
GSEnumerable<var> bulkJobs = response.BulkJobs;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createCancelBulkJobAdminRequest()
.setBulkJobIds(bulkJobIds)
.send(function(response:com.gamesparks.api.responses.CancelBulkJobAdminResponse):void {
var bulkJobs:Vector.<BulkJob> = response.getBulkJobs();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSCancelBulkJobAdminRequest* request = [[GSCancelBulkJobAdminRequest alloc] init];
[request setBulkJobIds:bulkJobIds;
[request setCallback:^ (GSCancelBulkJobAdminResponse* response) {
NSArray* bulkJobs = [response getBulkJobs];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void CancelBulkJobAdminRequest_Response(GS& gsInstance, const CancelBulkJobAdminResponse& response) {
gsstl:vector<Types::BulkJob*> bulkJobs = response.getBulkJobs();
GSData scriptData = response.getScriptData();
}
......
CancelBulkJobAdminRequest request(gsInstance);
request.SetBulkJobIds(bulkJobIds)
request.Send(CancelBulkJobAdminRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.CancelBulkJobAdminRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.CancelBulkJobAdminResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createCancelBulkJobAdminRequest()
.setBulkJobIds(bulkJobIds)
.send(new GSEventListener<CancelBulkJobAdminResponse>() {
@Override
public void onEvent(CancelBulkJobAdminResponse response) {
List<BulkJob> bulkJobs = response.getBulkJobs();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.CancelBulkJobAdminRequest();
request.bulkJobIds = ...;
var response = request.Send();
var bulkJobs = response.bulkJobs;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createCancelBulkJobAdminRequest();
request.setBulkJobIds(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var bulkJobs = response.bulkJobs;
var scriptData = response.scriptData;
});
Cancel one or more bulk jobs.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
bulkJobIds | Yes | string[] | The IDs of existing bulk jobs to cancel |
Response Parameters
A response listing cancelled bulk jobs
Parameter | Type | Description |
---|---|---|
bulkJobs | BulkJob[] | A list of JSON objects containing bulk jobs |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
bulkJobIds | REQUIRED | The bulkJobIds must be an array of one or more valid bulk job IDs |
ListBulkJobsAdminRequest
{
"@class" : ".ListBulkJobsAdminRequest",
"bulkJobIds" : [ "" ]
}
{
"@class" : ".ListBulkJobsAdminResponse",
"bulkJobs" : [ {
"actualCount" : 0,
"completed" : "2018-07-11T14:02Z",
"created" : "2018-07-11T14:02Z",
"data" : { },
"doneCount" : 0,
"errorCount" : 0,
"estimatedCount" : 0,
"id" : "",
"moduleShortCode" : "",
"playerQuery" : { },
"scheduledTime" : "2018-07-11T14:02Z",
"script" : "",
"started" : "2018-07-11T14:02Z",
"state" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListBulkJobsAdminRequest()
.SetBulkJobIds(bulkJobIds)
.Send((response) => {
GSEnumerable<var> bulkJobs = response.BulkJobs;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListBulkJobsAdminRequest()
.setBulkJobIds(bulkJobIds)
.send(function(response:com.gamesparks.api.responses.ListBulkJobsAdminResponse):void {
var bulkJobs:Vector.<BulkJob> = response.getBulkJobs();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListBulkJobsAdminRequest* request = [[GSListBulkJobsAdminRequest alloc] init];
[request setBulkJobIds:bulkJobIds;
[request setCallback:^ (GSListBulkJobsAdminResponse* response) {
NSArray* bulkJobs = [response getBulkJobs];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListBulkJobsAdminRequest_Response(GS& gsInstance, const ListBulkJobsAdminResponse& response) {
gsstl:vector<Types::BulkJob*> bulkJobs = response.getBulkJobs();
GSData scriptData = response.getScriptData();
}
......
ListBulkJobsAdminRequest request(gsInstance);
request.SetBulkJobIds(bulkJobIds)
request.Send(ListBulkJobsAdminRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListBulkJobsAdminRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListBulkJobsAdminResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListBulkJobsAdminRequest()
.setBulkJobIds(bulkJobIds)
.send(new GSEventListener<ListBulkJobsAdminResponse>() {
@Override
public void onEvent(ListBulkJobsAdminResponse response) {
List<BulkJob> bulkJobs = response.getBulkJobs();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListBulkJobsAdminRequest();
request.bulkJobIds = ...;
var response = request.Send();
var bulkJobs = response.bulkJobs;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListBulkJobsAdminRequest();
request.setBulkJobIds(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var bulkJobs = response.bulkJobs;
var scriptData = response.scriptData;
});
Lists existing bulk jobs.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
bulkJobIds | No | string[] | The IDs of existing bulk jobs to get details for |
Response Parameters
A response listing existing bulk jobs
Parameter | Type | Description |
---|---|---|
bulkJobs | BulkJob[] | A list of JSON objects containing bulk jobs |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
RevokePurchaseGoodsRequest
{
"@class" : ".RevokePurchaseGoodsRequest",
"playerId" : "",
"storeType" : "",
"transactionIds" : [ "" ]
}
{
"@class" : ".RevokePurchaseGoodsResponse",
"revokedGoods" : { },
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new RevokePurchaseGoodsRequest()
.SetPlayerId(playerId)
.SetStoreType(storeType)
.SetTransactionIds(transactionIds)
.Send((response) => {
GSData revokedGoods = response.RevokedGoods;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createRevokePurchaseGoodsRequest()
.setPlayerId(playerId)
.setStoreType(storeType)
.setTransactionIds(transactionIds)
.send(function(response:com.gamesparks.api.responses.RevokePurchaseGoodsResponse):void {
var revokedGoods:Object = response.getRevokedGoods();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSRevokePurchaseGoodsRequest* request = [[GSRevokePurchaseGoodsRequest alloc] init];
[request setPlayerId:playerId;
[request setStoreType:storeType;
[request setTransactionIds:transactionIds;
[request setCallback:^ (GSRevokePurchaseGoodsResponse* response) {
NSDictionary* revokedGoods = [response getRevokedGoods];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void RevokePurchaseGoodsRequest_Response(GS& gsInstance, const RevokePurchaseGoodsResponse& response) {
GSData revokedGoods = response.getRevokedGoods();
GSData scriptData = response.getScriptData();
}
......
RevokePurchaseGoodsRequest request(gsInstance);
request.SetPlayerId(playerId)
request.SetStoreType(storeType)
request.SetTransactionIds(transactionIds)
request.Send(RevokePurchaseGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.RevokePurchaseGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.RevokePurchaseGoodsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createRevokePurchaseGoodsRequest()
.setPlayerId(playerId)
.setStoreType(storeType)
.setTransactionIds(transactionIds)
.send(new GSEventListener<RevokePurchaseGoodsResponse>() {
@Override
public void onEvent(RevokePurchaseGoodsResponse response) {
GSData revokedGoods = response.getRevokedGoods();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.RevokePurchaseGoodsRequest();
request.playerId = ...;
request.storeType = ...;
request.transactionIds = ...;
var response = request.Send();
var revokedGoods = response.revokedGoods;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createRevokePurchaseGoodsRequest();
request.setPlayerId(...);
request.setStoreType(...);
request.setTransactionIds(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var revokedGoods = response.revokedGoods;
var scriptData = response.scriptData;
});
Revokes the purchase of a good. The items aquired will be removed from remaining items of the player.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
playerId | Yes | string | The playerId for which to revoke the transaction |
storeType | Yes | string | The store type for which to revoke these transactions |
transactionIds | Yes | string[] | The list of transactionIds to revoke |
Response Parameters
A response containing details of the revoked items
Parameter | Type | Description |
---|---|---|
revokedGoods | JSON | The map of revoked goods |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
transactionIds | REQUIRED | The transactionIds is missing |
storeType | REQUIRED | The storeType is missing |
playerId | REQUIRED | The playerId is missing |
ScheduleBulkJobAdminRequest
{
"@class" : ".ScheduleBulkJobAdminRequest",
"data" : { },
"moduleShortCode" : "",
"playerQuery" : { },
"scheduledTime" : "2018-07-11T14:02Z",
"script" : ""
}
{
"@class" : ".ScheduleBulkJobAdminResponse",
"estimatedCount" : 0,
"jobId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ScheduleBulkJobAdminRequest()
.SetData(data)
.SetModuleShortCode(moduleShortCode)
.SetPlayerQuery(playerQuery)
.SetScheduledTime(scheduledTime)
.SetScript(script)
.Send((response) => {
long? estimatedCount = response.EstimatedCount;
string jobId = response.JobId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createScheduleBulkJobAdminRequest()
.setData(data)
.setModuleShortCode(moduleShortCode)
.setPlayerQuery(playerQuery)
.setScheduledTime(scheduledTime)
.setScript(script)
.send(function(response:com.gamesparks.api.responses.ScheduleBulkJobAdminResponse):void {
var estimatedCount:Number = response.getEstimatedCount();
var jobId:String = response.getJobId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSScheduleBulkJobAdminRequest* request = [[GSScheduleBulkJobAdminRequest alloc] init];
[request setData:data;
[request setModuleShortCode:moduleShortCode;
[request setPlayerQuery:playerQuery;
[request setScheduledTime:scheduledTime;
[request setScript:script;
[request setCallback:^ (GSScheduleBulkJobAdminResponse* response) {
NSNumber* estimatedCount = [response getEstimatedCount];
NSString* jobId = [response getJobId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ScheduleBulkJobAdminRequest_Response(GS& gsInstance, const ScheduleBulkJobAdminResponse& response) {
Optional::t_LongOptional estimatedCount = response.getEstimatedCount();
gsstl::string jobId = response.getJobId();
GSData scriptData = response.getScriptData();
}
......
ScheduleBulkJobAdminRequest request(gsInstance);
request.SetData(data)
request.SetModuleShortCode(moduleShortCode)
request.SetPlayerQuery(playerQuery)
request.SetScheduledTime(scheduledTime)
request.SetScript(script)
request.Send(ScheduleBulkJobAdminRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ScheduleBulkJobAdminRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ScheduleBulkJobAdminResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createScheduleBulkJobAdminRequest()
.setData(data)
.setModuleShortCode(moduleShortCode)
.setPlayerQuery(playerQuery)
.setScheduledTime(scheduledTime)
.setScript(script)
.send(new GSEventListener<ScheduleBulkJobAdminResponse>() {
@Override
public void onEvent(ScheduleBulkJobAdminResponse response) {
Long estimatedCount = response.getEstimatedCount();
String jobId = response.getJobId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ScheduleBulkJobAdminRequest();
request.data = ...;
request.moduleShortCode = ...;
request.playerQuery = ...;
request.scheduledTime = ...;
request.script = ...;
var response = request.Send();
var estimatedCount = response.estimatedCount;
var jobId = response.jobId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createScheduleBulkJobAdminRequest();
request.setData(...);
request.setModuleShortCode(...);
request.setPlayerQuery(...);
request.setScheduledTime(...);
request.setScript(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var estimatedCount = response.estimatedCount;
var jobId = response.jobId;
var scriptData = response.scriptData;
});
Schedules a bulk job to be run against multiple players.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
data | No | DBObject | Optional data to be passed into the script |
moduleShortCode | No | string | The short code of the cloud code module to be executed against each player |
playerQuery | Yes | DBObject | The query to be run against the player collection to identify which players to execute the cloud code for |
scheduledTime | No | date | An optional date and time for this job to be run |
script | No | string | The script to be executed against each player |
Response Parameters
A response acknowledging the scheduling of a bulk job
Parameter | Type | Description |
---|---|---|
estimatedCount | number | The count of players who would be affected by this job if it ran at the time it was submitted |
jobId | string | The unique job ID, used to identify this job in future requests |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
moduleShortCode | INVALID | One of either the script or moduleShortCode properties must be populated |
script | Validation error | If an invalid script is supplied, the validation error will be returned here. |
scheduledTime | INVALID | The date/time for scheduled jobs must not be in the past |
Authentication
AmazonConnectRequest
{
"@class" : ".AmazonConnectRequest",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AmazonConnectRequest()
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAmazonConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAmazonConnectRequest* request = [[GSAmazonConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AmazonConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
AmazonConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(AmazonConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AmazonConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAmazonConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.AmazonConnectRequest();
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createAmazonConnectRequest();
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows an Amazon access token to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Amazon platform and store them within GameSparks.
If the Amazon user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Amazon user is not already registered with the game, the Amazon user will be linked to the current player.
If the current player has not authenticated and the Amazon user is not known, a new player will be created using the Amazon details and the session will be authenticated against the new player.
If the Amazon user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used by the client to make authenticated requests on behalf of the end user. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Amazon profile and it’s not the profile they have just tried to log in with |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | REQUIRED | The accessToken is missing |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
AuthenticationRequest
{
"@class" : ".AuthenticationRequest",
"password" : "",
"userName" : ""
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AuthenticationRequest()
.SetPassword(password)
.SetUserName(userName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAuthenticationRequest()
.setPassword(password)
.setUserName(userName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAuthenticationRequest* request = [[GSAuthenticationRequest alloc] init];
[request setPassword:password;
[request setUserName:userName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AuthenticationRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
AuthenticationRequest request(gsInstance);
request.SetPassword(password)
request.SetUserName(userName)
request.Send(AuthenticationRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AuthenticationRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAuthenticationRequest()
.setPassword(password)
.setUserName(userName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.AuthenticationRequest();
request.password = ...;
request.userName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createAuthenticationRequest();
request.setPassword(...);
request.setUserName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Provides authentication using a username/password combination.
The username will have been previously created using a RegistrationRequest.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
password | Yes | string | The previously registered password |
userName | Yes | string | The previously registered player name |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
DETAILS | UNRECOGNISED | The userName password combination did not match any existing account |
DETAILS | LOCKED | There have been too many failed login attempts with these details, the account has been locked temporarily |
DeviceAuthenticationRequest
{
"@class" : ".DeviceAuthenticationRequest",
"deviceId" : "",
"deviceModel" : "",
"deviceName" : "",
"deviceOS" : "",
"deviceType" : "",
"displayName" : "",
"operatingSystem" : "",
"segments" : { }
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new DeviceAuthenticationRequest()
.SetDeviceId(deviceId)
.SetDeviceModel(deviceModel)
.SetDeviceName(deviceName)
.SetDeviceOS(deviceOS)
.SetDeviceType(deviceType)
.SetDisplayName(displayName)
.SetOperatingSystem(operatingSystem)
.SetSegments(segments)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createDeviceAuthenticationRequest()
.setDeviceId(deviceId)
.setDeviceModel(deviceModel)
.setDeviceName(deviceName)
.setDeviceOS(deviceOS)
.setDeviceType(deviceType)
.setDisplayName(displayName)
.setOperatingSystem(operatingSystem)
.setSegments(segments)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSDeviceAuthenticationRequest* request = [[GSDeviceAuthenticationRequest alloc] init];
[request setDeviceId:deviceId;
[request setDeviceModel:deviceModel;
[request setDeviceName:deviceName;
[request setDeviceOS:deviceOS;
[request setDeviceType:deviceType;
[request setDisplayName:displayName;
[request setOperatingSystem:operatingSystem;
[request setSegments:segments;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void DeviceAuthenticationRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
DeviceAuthenticationRequest request(gsInstance);
request.SetDeviceId(deviceId)
request.SetDeviceModel(deviceModel)
request.SetDeviceName(deviceName)
request.SetDeviceOS(deviceOS)
request.SetDeviceType(deviceType)
request.SetDisplayName(displayName)
request.SetOperatingSystem(operatingSystem)
request.SetSegments(segments)
request.Send(DeviceAuthenticationRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.DeviceAuthenticationRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createDeviceAuthenticationRequest()
.setDeviceId(deviceId)
.setDeviceModel(deviceModel)
.setDeviceName(deviceName)
.setDeviceOS(deviceOS)
.setDeviceType(deviceType)
.setDisplayName(displayName)
.setOperatingSystem(operatingSystem)
.setSegments(segments)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.DeviceAuthenticationRequest();
request.deviceId = ...;
request.deviceModel = ...;
request.deviceName = ...;
request.deviceOS = ...;
request.deviceType = ...;
request.displayName = ...;
request.operatingSystem = ...;
request.segments = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createDeviceAuthenticationRequest();
request.setDeviceId(...);
request.setDeviceModel(...);
request.setDeviceName(...);
request.setDeviceOS(...);
request.setDeviceType(...);
request.setDisplayName(...);
request.setOperatingSystem(...);
request.setSegments(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a device id to be used to create an anonymous profile in the game.
This allows the player to be tracked and have data stored against them before using FacebookConnectRequest to create a full profile.
DeviceAuthenticationRequest should not be used in conjunction with RegistrationRequest as the two accounts will not be merged.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
deviceId | Yes | string | A unique device identifier. Each platform has it’s own method for getting a unique id |
deviceModel | No | string | The device model |
deviceName | No | string | The device name |
deviceOS | Yes | string | An indicator of the device platform, should be IOS, ANDROID, WP8 or W8 |
deviceType | No | string | The device type |
displayName | No | string | An optional displayname for the player |
operatingSystem | No | string | The device type |
segments | No | JSON | An optional segment configuration for this request. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
deviceOS | IOS | ANDROID |
FacebookConnectRequest
{
"@class" : ".FacebookConnectRequest",
"accessToken" : "",
"code" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new FacebookConnectRequest()
.SetAccessToken(accessToken)
.SetCode(code)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createFacebookConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSFacebookConnectRequest* request = [[GSFacebookConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setCode:code;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void FacebookConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
FacebookConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetCode(code)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(FacebookConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.FacebookConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createFacebookConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.FacebookConnectRequest();
request.accessToken = ...;
request.code = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createFacebookConnectRequest();
request.setAccessToken(...);
request.setCode(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows either a Facebook access token, or a Facebook authorization code to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Facebook platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Facebook user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthenticationRequest or RegistrationRequest AND the Facebook user is not already registered with the game, the Facebook user will be linked to the current player.
If the current player has not authenticated and the Facebook user is not known, a new player will be created using the Facebook details and the session will be authenticated against the new player.
If the Facebook user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used by the client to make authenticated requests on behalf of the end user. |
code | No | string | An authorization code is a short-lived token representing the user’s access grant, created by the authorization server and passed to the client application via the browser. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Facebook profile and it’s not the profile they have just tried to log in with |
code | NOTAUTHENTICATED | The system was unable to authenticate the code |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | REQUIRED | Both the code and the accessToken are missing |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
GameCenterConnectRequest
{
"@class" : ".GameCenterConnectRequest",
"displayName" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"externalPlayerId" : "",
"publicKeyUrl" : "",
"salt" : "",
"segments" : { },
"signature" : "",
"switchIfPossible" : false,
"syncDisplayName" : false,
"timestamp" : 0
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GameCenterConnectRequest()
.SetDisplayName(displayName)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetExternalPlayerId(externalPlayerId)
.SetPublicKeyUrl(publicKeyUrl)
.SetSalt(salt)
.SetSegments(segments)
.SetSignature(signature)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.SetTimestamp(timestamp)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGameCenterConnectRequest()
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setExternalPlayerId(externalPlayerId)
.setPublicKeyUrl(publicKeyUrl)
.setSalt(salt)
.setSegments(segments)
.setSignature(signature)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setTimestamp(timestamp)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGameCenterConnectRequest* request = [[GSGameCenterConnectRequest alloc] init];
[request setDisplayName:displayName;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setExternalPlayerId:externalPlayerId;
[request setPublicKeyUrl:publicKeyUrl;
[request setSalt:salt;
[request setSegments:segments;
[request setSignature:signature;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setTimestamp:timestamp;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GameCenterConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
GameCenterConnectRequest request(gsInstance);
request.SetDisplayName(displayName)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetExternalPlayerId(externalPlayerId)
request.SetPublicKeyUrl(publicKeyUrl)
request.SetSalt(salt)
request.SetSegments(segments)
request.SetSignature(signature)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.SetTimestamp(timestamp)
request.Send(GameCenterConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GameCenterConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGameCenterConnectRequest()
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setExternalPlayerId(externalPlayerId)
.setPublicKeyUrl(publicKeyUrl)
.setSalt(salt)
.setSegments(segments)
.setSignature(signature)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setTimestamp(timestamp)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.GameCenterConnectRequest();
request.displayName = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.externalPlayerId = ...;
request.publicKeyUrl = ...;
request.salt = ...;
request.segments = ...;
request.signature = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
request.timestamp = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createGameCenterConnectRequest();
request.setDisplayName(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setExternalPlayerId(...);
request.setPublicKeyUrl(...);
request.setSalt(...);
request.setSegments(...);
request.setSignature(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
request.setTimestamp(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows an Apple account that has GameCenter to be used as an authentication mechanism.
The request must supply the GameCenter user details, such as the player id and username.
If the GameCenter user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the GameCenter user is not already registered with the game, the GameCenter user will be linked to the current player.
If the current player has not authenticated and the GameCenter user is not known, a new player will be created using the GameCenter details and the session will be authenticated against the new player.
If the GameCenter user is already known, the session will switch to being the previously created user.
This API call requires the output details from GKLocalPlayer.generateIdentityVerificationSignatureWithCompletionHandler on your iOS device
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
displayName | No | string | The display of the current player from GameCenter. This will be used as the displayName of the gamesparks player if created (or syncDisplayname is true) |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
externalPlayerId | No | string | The game center id of the current player. This value obtained be obtained from GKLocalPlayer playerID |
publicKeyUrl | No | string | The url from where we will download the public key. This value should be obtained from generateIdentityVerificationSignatureWithCompletionHandler. |
salt | No | string | The salt is needed in order to prevent request forgery. This value should be obtained from generateIdentityVerificationSignatureWithCompletionHandler and should be base64 encoded using [salt base64Encoding] |
segments | No | JSON | An optional segment configuration for this request. |
signature | No | string | The signature is needed to validate that the request is genuine and that we can save the player. This value should be obtained from generateIdentityVerificationSignatureWithCompletionHandler and should be base64 encoded using [signature base64Encoding] |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
timestamp | No | number | The timestamp is needed to validate the request signature. This value should be obtained from generateIdentityVerificationSignatureWithCompletionHandler |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
externalPlayerId | ACCOUNT_ALREADY_LINKED | The current user has a GameCenter profile and it’s not the profile they have just tried to log in with |
signature | NOTAUTHENTICATED | The system was unable to validate the request |
externalPlayerId | NOTAUTHENTICATED | The system was unable to validate the external player ID |
publicKeyUrl | REQUIRED | The publicKeyUrl is required but not provided |
timestamp | REQUIRED | The timestamp is required but not provided |
timestamp | EXPIRED | The request expired |
signature | REQUIRED | The signature is required but not provided |
salt | REQUIRED | The salt is required but not provided |
externalPlayerId | REQUIRED | The externalPlayerId is required but not provided |
displayName | REQUIRED | The displayName is required but not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
GooglePlayConnectRequest
{
"@class" : ".GooglePlayConnectRequest",
"accessToken" : "",
"code" : "",
"displayName" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"googlePlusScope" : false,
"profileScope" : false,
"redirectUri" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GooglePlayConnectRequest()
.SetAccessToken(accessToken)
.SetCode(code)
.SetDisplayName(displayName)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetGooglePlusScope(googlePlusScope)
.SetProfileScope(profileScope)
.SetRedirectUri(redirectUri)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGooglePlayConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setGooglePlusScope(googlePlusScope)
.setProfileScope(profileScope)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGooglePlayConnectRequest* request = [[GSGooglePlayConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setCode:code;
[request setDisplayName:displayName;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setGooglePlusScope:googlePlusScope;
[request setProfileScope:profileScope;
[request setRedirectUri:redirectUri;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GooglePlayConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
GooglePlayConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetCode(code)
request.SetDisplayName(displayName)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetGooglePlusScope(googlePlusScope)
request.SetProfileScope(profileScope)
request.SetRedirectUri(redirectUri)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(GooglePlayConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GooglePlayConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGooglePlayConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setGooglePlusScope(googlePlusScope)
.setProfileScope(profileScope)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.GooglePlayConnectRequest();
request.accessToken = ...;
request.code = ...;
request.displayName = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.googlePlusScope = ...;
request.profileScope = ...;
request.redirectUri = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createGooglePlayConnectRequest();
request.setAccessToken(...);
request.setCode(...);
request.setDisplayName(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setGooglePlusScope(...);
request.setProfileScope(...);
request.setRedirectUri(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows either a Google Play access code or an access token to be used as an authentication mechanism.
The access code needs to have at least the https://www.googleapis.com/auth/games scope.
For more details about Google OAuth 2.0 scopes refer to this: https://developers.google.com/identity/protocols/googlescopes#gamesConfigurationv1configuration
If the Google Play user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Google Play user is not already registered with the game, the Google Play user will be linked to the current player.
If the current player has not authenticated and the Google Play user is not known, a new player will be created using the Google Play details and the session will be authenticated against the new player.
If the Google Play user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used when using the service id and certificate. |
code | No | string | The access code is used by the client to make authenticated requests on behalf of the end user. Requires clientId and clientsecret to be set |
displayName | No | string | The display of the current player from Google Play. This will be used as the displayName of the gamesparks player if created (or syncDisplayname is true) |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
googlePlusScope | No | boolean | Did you request the plus.login scope when you got the access code or authorisation token from Google? If this is true, we will fetch the user’s google+ account and friends |
profileScope | No | boolean | Did you request the profile scope when you got the access code or authorisation token from Google? If this is true, we will fetch the user info by calling https://www.googleapis.com/oauth2/v1/userinfo?alt=json |
redirectUri | No | string | Only required when the access code has been granted using an explicit redirectUri, for example when using the mechanism described in https://developers.google.com/+/web/signin/server-side-flow |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
code | NOTAUTHENTICATED | The system was unable to authenticate the code |
accessToken|code | REQUIRED | Both the code and the accessToken are missing |
displayName | REQUIRED | The displayName is missing |
GOOGLE_PLAY | NOT_CONFIGURED | The game has not been configured with the required Google Play App ID |
GOOGLE_PLUS | NOT_CONFIGURED | Google+ scope is requested, but the game has not been configured with the required Google Plus integration credentials: the client ID and the client secret |
redirectUri | REQUIRED | The redirectUri is required when using a code rather than an accessToken |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
GooglePlusConnectRequest
{
"@class" : ".GooglePlusConnectRequest",
"accessToken" : "",
"code" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"redirectUri" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GooglePlusConnectRequest()
.SetAccessToken(accessToken)
.SetCode(code)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetRedirectUri(redirectUri)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGooglePlusConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGooglePlusConnectRequest* request = [[GSGooglePlusConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setCode:code;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setRedirectUri:redirectUri;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GooglePlusConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
GooglePlusConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetCode(code)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetRedirectUri(redirectUri)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(GooglePlusConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GooglePlusConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGooglePlusConnectRequest()
.setAccessToken(accessToken)
.setCode(code)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.GooglePlusConnectRequest();
request.accessToken = ...;
request.code = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.redirectUri = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createGooglePlusConnectRequest();
request.setAccessToken(...);
request.setCode(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setRedirectUri(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows either a Google Plus access code or an authentication token to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Google Plus platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Google Plus user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Google Plus user is not already registered with the game, the Google Plus user will be linked to the current player.
If the current player has not authenticated and the Google Plus user is not known, a new player will be created using the Google Plus details and the session will be authenticated against the new player.
If the Google Plus user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used when using the service id and certificate. |
code | No | string | The access code is used by the client to make authenticated requests on behalf of the end user. Requires clientId and clientsecret to be set |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
redirectUri | No | string | Only required when the access code has been granted using an explicit redirectUri, for example when using the mechanism described in https://developers.google.com/+/web/signin/server-side-flow |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
code | NOTAUTHENTICATED | The system was unable to authenticate the code |
accessToken|code | REQUIRED | Both the code and the accessToken are missing |
GOOGLE_PLUS | NOT_CONFIGURED | The game has not been configured with the required Google Plus integration credentials |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
KongregateConnectRequest
{
"@class" : ".KongregateConnectRequest",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"gameAuthToken" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false,
"userId" : ""
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new KongregateConnectRequest()
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetGameAuthToken(gameAuthToken)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.SetUserId(userId)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createKongregateConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setGameAuthToken(gameAuthToken)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setUserId(userId)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSKongregateConnectRequest* request = [[GSKongregateConnectRequest alloc] init];
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setGameAuthToken:gameAuthToken;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setUserId:userId;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void KongregateConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
KongregateConnectRequest request(gsInstance);
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetGameAuthToken(gameAuthToken)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.SetUserId(userId)
request.Send(KongregateConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.KongregateConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createKongregateConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setGameAuthToken(gameAuthToken)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setUserId(userId)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.KongregateConnectRequest();
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.gameAuthToken = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
request.userId = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createKongregateConnectRequest();
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setGameAuthToken(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
request.setUserId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a Kongregate account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Kongregate platform and store them within GameSparks.
If the Kongregate user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Kongregate user is not already registered with the game, the Kongregate user will be linked to the current player.
If the current player has not authenticated and the Kongregate user is not known, a new player will be created using the Kongregate details and the session will be authenticated against the new player.
If the Kongregate user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
gameAuthToken | No | string | The gameAuthToken, together with the userID are used by the client to make authenticated requests on behalf of the end user. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
userId | No | string | The userID, together with the gameAuthToken are used by the client to make authenticated requests on behalf of the end user. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
userId | ACCOUNT_ALREADY_LINKED | The current user has a Kongregate profile and it’s not the profile they have just tried to log in with |
gameAuthToken | NOTAUTHENTICATED | The system was unable to authenticate the user id |
gameAuthToken | NOTAUTHENTICATED | The system was unable to authenticate the user |
userId | REQUIRED | The userId is required but not provided |
gameAuthToken | REQUIRED | The gameAuthToken is required but not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
NXConnectRequest
{
"@class" : ".NXConnectRequest",
"accountPerLoginId" : false,
"displayName" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"nsaIdToken" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new NXConnectRequest()
.SetAccountPerLoginId(accountPerLoginId)
.SetDisplayName(displayName)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetNsaIdToken(nsaIdToken)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createNXConnectRequest()
.setAccountPerLoginId(accountPerLoginId)
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setNsaIdToken(nsaIdToken)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSNXConnectRequest* request = [[GSNXConnectRequest alloc] init];
[request setAccountPerLoginId:accountPerLoginId;
[request setDisplayName:displayName;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setNsaIdToken:nsaIdToken;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void NXConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
NXConnectRequest request(gsInstance);
request.SetAccountPerLoginId(accountPerLoginId)
request.SetDisplayName(displayName)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetNsaIdToken(nsaIdToken)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(NXConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.NXConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createNXConnectRequest()
.setAccountPerLoginId(accountPerLoginId)
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setNsaIdToken(nsaIdToken)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.NXConnectRequest();
request.accountPerLoginId = ...;
request.displayName = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.nsaIdToken = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createNXConnectRequest();
request.setAccountPerLoginId(...);
request.setDisplayName(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setNsaIdToken(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows an Nintendo Network Service Account (NSA) to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the NSA and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the NSA is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the NSA is not already registered with the game, the NSA will be linked to the current player.
If the current player has not authenticated and the NSA is not known, a new player will be created using the NSA details and the session will be authenticated against the new player.
If the NSA is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accountPerLoginId | No | boolean | Whether to create one GameSparks player per console login ID |
displayName | No | string | The display name of the current player from NX. This will be used as the displayName of the gamesparks player if created (or syncDisplayname is true) |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
nsaIdToken | No | string | The NSA ID token obtained from Nintendo |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
NX | NOT_CONFIGURED | The game does not have the NX integration details configured. |
nsaIdToken | NOTAUTHENTICATED | The system was unable to authenticate the NSA ID token |
nsaIdToken | REQUIRED | Parameter nsaIdToken is required but was not provided |
accessToken | ACCOUNT_ALREADY_LINKED | The current user has an NSA profile and it’s not the profile they have just tried to log in with |
displayName | REQUIRED | Parameter displayName is required but not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
PSNAccountConnectRequest
{
"@class" : ".PSNAccountConnectRequest",
"authorizationCode" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"redirectUri" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new PSNAccountConnectRequest()
.SetAuthorizationCode(authorizationCode)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetRedirectUri(redirectUri)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createPSNAccountConnectRequest()
.setAuthorizationCode(authorizationCode)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSPSNAccountConnectRequest* request = [[GSPSNAccountConnectRequest alloc] init];
[request setAuthorizationCode:authorizationCode;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setRedirectUri:redirectUri;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void PSNAccountConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
PSNAccountConnectRequest request(gsInstance);
request.SetAuthorizationCode(authorizationCode)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetRedirectUri(redirectUri)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(PSNAccountConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.PSNAccountConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createPSNAccountConnectRequest()
.setAuthorizationCode(authorizationCode)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.PSNAccountConnectRequest();
request.authorizationCode = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.redirectUri = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createPSNAccountConnectRequest();
request.setAuthorizationCode(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setRedirectUri(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a PSN account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the PSN platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the PSN user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the PSN user is not already registered with the game, the PSN user will be linked to the current player.
If the current player has not authenticated and the PSN user is not known, a new player will be created using the PSN details and the session will be authenticated against the new player.
If the PSN user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
authorizationCode | No | string | The authorization code obtained from PSN, as described here https://ps4.scedev.net/resources/documents/SDK/latest/NpAuth-Reference/0008.html |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
redirectUri | No | string | When using the authorization code obtained from PlayStation®4/PlayStation®Vita/PlayStation®3, this is not required. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
PSN | NOT_CONFIGURED | The game does not have the PSN integration details configured. |
authorizationCode | NOTAUTHENTICATED | The system was unable to authenticate the authorizationCode |
authorizationCode | ACCOUNT_ALREADY_LINKED | The current user has a PSN profile and it’s not the profile they have just tried to log in with |
authorizationCode | REQUIRED | Parameter authorizationCode is required but was not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
PSNConnectRequest
{
"@class" : ".PSNConnectRequest",
"authorizationCode" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"redirectUri" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new PSNConnectRequest()
.SetAuthorizationCode(authorizationCode)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetRedirectUri(redirectUri)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createPSNConnectRequest()
.setAuthorizationCode(authorizationCode)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSPSNConnectRequest* request = [[GSPSNConnectRequest alloc] init];
[request setAuthorizationCode:authorizationCode;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setRedirectUri:redirectUri;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void PSNConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
PSNConnectRequest request(gsInstance);
request.SetAuthorizationCode(authorizationCode)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetRedirectUri(redirectUri)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(PSNConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.PSNConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createPSNConnectRequest()
.setAuthorizationCode(authorizationCode)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setRedirectUri(redirectUri)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.PSNConnectRequest();
request.authorizationCode = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.redirectUri = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createPSNConnectRequest();
request.setAuthorizationCode(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setRedirectUri(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
DEPRECATED - Use PSNAccountConnectRequest instead.
Allows a PSN account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the PSN platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the PSN user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the PSN user is not already registered with the game, the PSN user will be linked to the current player.
If the current player has not authenticated and the PSN user is not known, a new player will be created using the PSN details and the session will be authenticated against the new player.
If the PSN user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
authorizationCode | No | string | The authorization code obtained from PSN, as described here https://ps4.scedev.net/resources/documents/SDK/latest/NpAuth-Reference/0008.html |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
redirectUri | No | string | When using the authorization code obtained from PlayStation®4/PlayStation®Vita/PlayStation®3, this is not required. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
PSN | NOT_CONFIGURED | The game does not have the PSN integration details configured. |
authorizationCode | NOTAUTHENTICATED | The system was unable to authenticate the authorizationCode |
authorizationCode | ACCOUNT_ALREADY_LINKED | The current user has a PSN profile and it’s not the profile they have just tried to log in with |
authorizationCode | REQUIRED | Parameter authorizationCode is required but was not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
QQConnectRequest
{
"@class" : ".QQConnectRequest",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new QQConnectRequest()
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createQQConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSQQConnectRequest* request = [[GSQQConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void QQConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
QQConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(QQConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.QQConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createQQConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.QQConnectRequest();
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createQQConnectRequest();
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a QQ access token to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the QQ platform and store them within GameSparks.
If the QQ user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthenticationRequest or RegistrationRequest AND the QQ user is not already registered with the game, the QQ user will be linked to the current player.
If the current player has not authenticated and the QQ user is not known, a new player will be created using the QQ details and the session will be authenticated against the new player.
If the QQ user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used by the client to make authenticated requests on behalf of the end user. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a QQ profile and it’s not the profile they have just tried to log in with |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | REQUIRED | The accessToken is missing |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
RegistrationRequest
{
"@class" : ".RegistrationRequest",
"displayName" : "",
"password" : "",
"segments" : { },
"userName" : ""
}
{
"@class" : ".RegistrationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new RegistrationRequest()
.SetDisplayName(displayName)
.SetPassword(password)
.SetSegments(segments)
.SetUserName(userName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createRegistrationRequest()
.setDisplayName(displayName)
.setPassword(password)
.setSegments(segments)
.setUserName(userName)
.send(function(response:com.gamesparks.api.responses.RegistrationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSRegistrationRequest* request = [[GSRegistrationRequest alloc] init];
[request setDisplayName:displayName;
[request setPassword:password;
[request setSegments:segments;
[request setUserName:userName;
[request setCallback:^ (GSRegistrationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void RegistrationRequest_Response(GS& gsInstance, const RegistrationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
RegistrationRequest request(gsInstance);
request.SetDisplayName(displayName)
request.SetPassword(password)
request.SetSegments(segments)
request.SetUserName(userName)
request.Send(RegistrationRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.RegistrationRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.RegistrationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createRegistrationRequest()
.setDisplayName(displayName)
.setPassword(password)
.setSegments(segments)
.setUserName(userName)
.send(new GSEventListener<RegistrationResponse>() {
@Override
public void onEvent(RegistrationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.RegistrationRequest();
request.displayName = ...;
request.password = ...;
request.segments = ...;
request.userName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createRegistrationRequest();
request.setDisplayName(...);
request.setPassword(...);
request.setSegments(...);
request.setUserName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a new player to be created using a username, password display name.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
displayName | Yes | string | A display name to use |
password | Yes | string | The previously registered password |
segments | No | JSON | An optional segment configuration for this request. |
userName | Yes | string | The previously registered player name |
Response Parameters
A response to a registration request
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
USERNAME | TAKEN | The userName supplied is already in use. |
SteamConnectRequest
{
"@class" : ".SteamConnectRequest",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"sessionTicket" : "",
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SteamConnectRequest()
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSessionTicket(sessionTicket)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSteamConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSessionTicket(sessionTicket)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSteamConnectRequest* request = [[GSSteamConnectRequest alloc] init];
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSessionTicket:sessionTicket;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SteamConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
SteamConnectRequest request(gsInstance);
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSessionTicket(sessionTicket)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(SteamConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SteamConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSteamConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSessionTicket(sessionTicket)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.SteamConnectRequest();
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.sessionTicket = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createSteamConnectRequest();
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSessionTicket(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a Steam sessionTicket to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Steam platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Steam user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Steam user is not already registered with the game, the Steam user will be linked to the current player.
If the current player has not authenticated and the Steam user is not known, a new player will be created using the Steam details and the session will be authenticated against the new player.
If the Steam user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
sessionTicket | No | string | The hex encoded UTF-8 string representation of the ticket acquired calling the Steam SDKs GetAuthSessionTicket. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
sessionTicket | ACCOUNT_ALREADY_LINKED | The current user has a Steam profile and it’s not the profile they have just tried to log in with |
sessionTicket | NOTAUTHENTICATED | The system was unable to authenticate the sessionTicket |
sessionTicket | REQUIRED | Parameter sessionTicket is required but was not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
TwitchConnectRequest
{
"@class" : ".TwitchConnectRequest",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new TwitchConnectRequest()
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createTwitchConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSTwitchConnectRequest* request = [[GSTwitchConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void TwitchConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
TwitchConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(TwitchConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.TwitchConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createTwitchConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.TwitchConnectRequest();
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createTwitchConnectRequest();
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a Twitch account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Twitch platform and store them within GameSparks.
If the Twitch user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Twitch user is not already registered with the game, the Twitch user will be linked to the current player.
If the current player has not authenticated and the Twitch user is not known, a new player will be created using the Twitch details and the session will be authenticated against the new player.
If the Twitch user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token is used by the client to make authenticated requests on behalf of the end user. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Twitch profile and it’s not the profile they have just tried to log in with |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | REQUIRED | The accessToken is required but not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
TwitterConnectRequest
{
"@class" : ".TwitterConnectRequest",
"accessSecret" : "",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new TwitterConnectRequest()
.SetAccessSecret(accessSecret)
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createTwitterConnectRequest()
.setAccessSecret(accessSecret)
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSTwitterConnectRequest* request = [[GSTwitterConnectRequest alloc] init];
[request setAccessSecret:accessSecret;
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void TwitterConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
TwitterConnectRequest request(gsInstance);
request.SetAccessSecret(accessSecret)
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(TwitterConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.TwitterConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createTwitterConnectRequest()
.setAccessSecret(accessSecret)
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.TwitterConnectRequest();
request.accessSecret = ...;
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createTwitterConnectRequest();
request.setAccessSecret(...);
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a Twitter account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Twitter platform and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Twitter user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Twitter user is not already registered with the game, the Twitter user will be linked to the current player.
If the current player has not authenticated and the Twitter user is not known, a new player will be created using the Twitter details and the session will be authenticated against the new player.
If the Twitter user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessSecret | No | string | The accessSecret is obtained at the same time as the accessToken, and is required to sign requests to Twitter’s services that require the accessToken. |
accessToken | No | string | The accessToken represents a player’s permission to share access to their account with your application. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Twitter profile and it’s not the profile they have just tried to log in with |
accessToken | REQUIRED | Parameter accessToken is required but was not provided |
accessSecret | REQUIRED | Parameter accessSecret is required but was not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
ViberConnectRequest
{
"@class" : ".ViberConnectRequest",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"doNotRegisterForPush" : false,
"errorOnSwitch" : false,
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ViberConnectRequest()
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetDoNotRegisterForPush(doNotRegisterForPush)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createViberConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setDoNotRegisterForPush(doNotRegisterForPush)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSViberConnectRequest* request = [[GSViberConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setDoNotRegisterForPush:doNotRegisterForPush;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ViberConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
ViberConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetDoNotRegisterForPush(doNotRegisterForPush)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(ViberConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ViberConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createViberConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setDoNotRegisterForPush(doNotRegisterForPush)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.ViberConnectRequest();
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.doNotRegisterForPush = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createViberConnectRequest();
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setDoNotRegisterForPush(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a Viber account to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Viber platform and store them within GameSparks.
A successful authentication will also register the player to receive Viber push notifications.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Viber user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Viber user is not already registered with the game, the Viber user will be linked to the current player.
If the current player has not authenticated and the Viber user is not known, a new player will be created using the Viber details and the session will be authenticated against the new player.
If the Viber user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | Yes | string | The accessToken represents a player’s permission to share access to their account with your application. |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
doNotRegisterForPush | No | boolean | Does not automatocally register this user for push notifications. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
viber | NOT_ENABLED | Viber integration is available by request only, this game does not have viber integration enabled |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Viber profile and it’s not the profile they have just tried to log in with |
accessToken | REQUIRED | Parameter accessToken is required but was not provided |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
WeChatConnectRequest
{
"@class" : ".WeChatConnectRequest",
"accessToken" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"openId" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new WeChatConnectRequest()
.SetAccessToken(accessToken)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetOpenId(openId)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createWeChatConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setOpenId(openId)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSWeChatConnectRequest* request = [[GSWeChatConnectRequest alloc] init];
[request setAccessToken:accessToken;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setOpenId:openId;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void WeChatConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
WeChatConnectRequest request(gsInstance);
request.SetAccessToken(accessToken)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetOpenId(openId)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(WeChatConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.WeChatConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createWeChatConnectRequest()
.setAccessToken(accessToken)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setOpenId(openId)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.WeChatConnectRequest();
request.accessToken = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.openId = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createWeChatConnectRequest();
request.setAccessToken(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setOpenId(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows a WeChat access token to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the WeChat platform and store them within GameSparks.
If the WeChat user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthenticationRequest or RegistrationRequest AND the WeChat user is not already registered with the game, the WeChat user will be linked to the current player.
If the current player has not authenticated and the WeChat user is not known, a new player will be created using the WeChat details and the session will be authenticated against the new player.
If the WeChat user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessToken | No | string | The access token sould be obtained from WeChat |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
openId | No | string | The open ID corresponding to the WeChat user |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a WeChat profile and it’s not the profile they have just tried to log in with |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
accessToken | REQUIRED | The accessToken is missing |
openId | REQUIRED | The openId is missing |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
XBOXLiveConnectRequest
{
"@class" : ".XBOXLiveConnectRequest",
"displayName" : "",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"segments" : { },
"stsTokenString" : "",
"switchIfPossible" : false,
"syncDisplayName" : false
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new XBOXLiveConnectRequest()
.SetDisplayName(displayName)
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSegments(segments)
.SetStsTokenString(stsTokenString)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createXBOXLiveConnectRequest()
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setStsTokenString(stsTokenString)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSXBOXLiveConnectRequest* request = [[GSXBOXLiveConnectRequest alloc] init];
[request setDisplayName:displayName;
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSegments:segments;
[request setStsTokenString:stsTokenString;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void XBOXLiveConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
XBOXLiveConnectRequest request(gsInstance);
request.SetDisplayName(displayName)
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSegments(segments)
request.SetStsTokenString(stsTokenString)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.Send(XBOXLiveConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.XBOXLiveConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createXBOXLiveConnectRequest()
.setDisplayName(displayName)
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSegments(segments)
.setStsTokenString(stsTokenString)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.XBOXLiveConnectRequest();
request.displayName = ...;
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.segments = ...;
request.stsTokenString = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createXBOXLiveConnectRequest();
request.setDisplayName(...);
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSegments(...);
request.setStsTokenString(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows an Xbox Live Shared Token String to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from the Xbox Live and store them within GameSparks.
GameSparks will determine the player’s friends and whether any of them are currently registered with the game.
If the Xbox user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Xbox user is not already registered with the game, the Xbox user will be linked to the current player.
If the current player has not authenticated and the Xbox user is not known, a new player will be created using the Xbox details and the session will be authenticated against the new player.
If the Xbox user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
displayName | No | string | The displayName to set for the player in GameSparks |
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
segments | No | JSON | An optional segment configuration for this request. |
stsTokenString | No | string | The access token is used by the client to make authenticated requests on behalf of the end user. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Xbox profile and it’s not the profile they have just tried to log in with |
code | NOTAUTHENTICATED | The system was unable to authenticate the code |
accessToken | NOTAUTHENTICATED | The system was unable to authenticate the token |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
XboxOneConnectRequest
{
"@class" : ".XboxOneConnectRequest",
"doNotCreateNewPlayer" : false,
"doNotLinkToCurrentPlayer" : false,
"errorOnSwitch" : false,
"sandbox" : "",
"segments" : { },
"switchIfPossible" : false,
"syncDisplayName" : false,
"token" : ""
}
{
"@class" : ".AuthenticationResponse",
"authToken" : "",
"displayName" : "",
"newPlayer" : false,
"scriptData" : { },
"switchSummary" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"userId" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new XboxOneConnectRequest()
.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.SetErrorOnSwitch(errorOnSwitch)
.SetSandbox(sandbox)
.SetSegments(segments)
.SetSwitchIfPossible(switchIfPossible)
.SetSyncDisplayName(syncDisplayName)
.SetToken(token)
.Send((response) => {
string authToken = response.AuthToken;
string displayName = response.DisplayName;
bool? newPlayer = response.NewPlayer;
GSData scriptData = response.ScriptData;
var switchSummary = response.SwitchSummary;
string userId = response.UserId;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createXboxOneConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSandbox(sandbox)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setToken(token)
.send(function(response:com.gamesparks.api.responses.AuthenticationResponse):void {
var authToken:String = response.getAuthToken();
var displayName:String = response.getDisplayName();
var newPlayer:Boolean = response.getNewPlayer();
var scriptData:ScriptData = response.getScriptData();
var switchSummary:Player = response.getSwitchSummary();
var userId:String = response.getUserId();
});
#import "GS.h"
#import "GSAPI.h"
...
GSXboxOneConnectRequest* request = [[GSXboxOneConnectRequest alloc] init];
[request setDoNotCreateNewPlayer:doNotCreateNewPlayer;
[request setDoNotLinkToCurrentPlayer:doNotLinkToCurrentPlayer;
[request setErrorOnSwitch:errorOnSwitch;
[request setSandbox:sandbox;
[request setSegments:segments;
[request setSwitchIfPossible:switchIfPossible;
[request setSyncDisplayName:syncDisplayName;
[request setToken:token;
[request setCallback:^ (GSAuthenticationResponse* response) {
NSString* authToken = [response getAuthToken];
NSString* displayName = [response getDisplayName];
BOOL newPlayer = [response getNewPlayer];
NSDictionary* scriptData = [response getScriptData];
GSPlayer* switchSummary = [response getSwitchSummary];
NSString* userId = [response getUserId];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void XboxOneConnectRequest_Response(GS& gsInstance, const AuthenticationResponse& response) {
gsstl::string authToken = response.getAuthToken();
gsstl::string displayName = response.getDisplayName();
Optional::t_BoolOptional newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Types::Player* switchSummary = response.getSwitchSummary();
gsstl::string userId = response.getUserId();
}
......
XboxOneConnectRequest request(gsInstance);
request.SetDoNotCreateNewPlayer(doNotCreateNewPlayer)
request.SetDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
request.SetErrorOnSwitch(errorOnSwitch)
request.SetSandbox(sandbox)
request.SetSegments(segments)
request.SetSwitchIfPossible(switchIfPossible)
request.SetSyncDisplayName(syncDisplayName)
request.SetToken(token)
request.Send(XboxOneConnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.XboxOneConnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AuthenticationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createXboxOneConnectRequest()
.setDoNotCreateNewPlayer(doNotCreateNewPlayer)
.setDoNotLinkToCurrentPlayer(doNotLinkToCurrentPlayer)
.setErrorOnSwitch(errorOnSwitch)
.setSandbox(sandbox)
.setSegments(segments)
.setSwitchIfPossible(switchIfPossible)
.setSyncDisplayName(syncDisplayName)
.setToken(token)
.send(new GSEventListener<AuthenticationResponse>() {
@Override
public void onEvent(AuthenticationResponse response) {
String authToken = response.getAuthToken();
String displayName = response.getDisplayName();
Boolean newPlayer = response.getNewPlayer();
GSData scriptData = response.getScriptData();
Player switchSummary = response.getSwitchSummary();
String userId = response.getUserId();
}
});
var request = new SparkRequests.XboxOneConnectRequest();
request.doNotCreateNewPlayer = ...;
request.doNotLinkToCurrentPlayer = ...;
request.errorOnSwitch = ...;
request.sandbox = ...;
request.segments = ...;
request.switchIfPossible = ...;
request.syncDisplayName = ...;
request.token = ...;
var response = request.Send();
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
var request = RTSession.newRequest().createXboxOneConnectRequest();
request.setDoNotCreateNewPlayer(...);
request.setDoNotLinkToCurrentPlayer(...);
request.setErrorOnSwitch(...);
request.setSandbox(...);
request.setSegments(...);
request.setSwitchIfPossible(...);
request.setSyncDisplayName(...);
request.setToken(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var authToken = response.authToken;
var displayName = response.displayName;
var newPlayer = response.newPlayer;
var scriptData = response.scriptData;
var switchSummary = response.switchSummary;
var userId = response.userId;
});
Allows an Xbox One XSTS token to be used as an authentication mechanism.
Once authenticated the platform can determine the current players details from Xbox Live and store them within GameSparks.
If the Xbox One user is already linked to a player, the current session will switch to the linked player.
If the current player has previously created an account using either DeviceAuthentictionRequest or RegistrationRequest AND the Xbox One user is not already registered with the game, the Xbox One user will be linked to the current player.
If the current player has not authenticated and the Xbox One user is not known, a new player will be created using the Xbox Live details and the session will be authenticated against the new player.
If the Xbox One user is already known, the session will switch to being the previously created user.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
doNotCreateNewPlayer | No | boolean | Indicates whether the server should return an error if a new player would have been registered, rather than creating the player. Defaults to false. |
doNotLinkToCurrentPlayer | No | boolean | Indicates that the server should not try to link the external profile with the current player. If false, links the external profile to the currently signed in player. If true, creates a new player and links the external profile to them. Defaults to false. |
errorOnSwitch | No | boolean | Indicates whether the server should return an error if an account switch would have occurred, rather than switching automatically. Defaults to false. |
sandbox | No | string | The Xbox Live sandbox to use. If not specified, the sandbox from the decoded token will be used. |
segments | No | JSON | An optional segment configuration for this request. |
switchIfPossible | No | boolean | Indicates that the server should switch to the supplied profile if it isalready associated to a player. Defaults to false. |
syncDisplayName | No | boolean | Indicates that the associated players displayName should be kept in syn with this profile when it’s updated by the external provider. |
token | No | string | The Xbox One authentication token |
Response Parameters
A response containing the auth token
Parameter | Type | Description |
---|---|---|
authToken | string | 44b297a8-162a-4220-8c14-dad9a1946ad2 |
displayName | string | The player’s display name |
newPlayer | boolean | Indicates whether the player was created as part of this request |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
switchSummary | Player | A summary of the player that would be switched to. Only returned as part of an error response for a request where automatic switching is disabled. |
userId | string | The player’s id |
Error Codes
Key | Value | Description |
---|---|---|
accessToken | ACCOUNT_ALREADY_LINKED | The current user has a Xbox One profile and it’s not the profile they have just tried to log in with |
token | NOTAUTHENTICATED | The system was unable to authenticate the token |
authentication | COPPA restricted | Social authentications are not allowed on COPPA compliant credentials due to social accounts containing personally identifiable information |
Leaderboards
AroundMeLeaderboardRequest
{
"@class" : ".AroundMeLeaderboardRequest",
"challengeInstanceId" : "",
"customIdFilter" : { },
"dontErrorOnNotSocial" : false,
"entryCount" : 0,
"friendIds" : [ "" ],
"includeFirst" : 0,
"includeLast" : 0,
"inverseSocial" : false,
"leaderboardShortCode" : "",
"social" : false,
"teamIds" : [ "" ],
"teamTypes" : [ "" ]
}
{
"@class" : ".AroundMeLeaderboardResponse",
"challengeInstanceId" : "",
"data" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"first" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"last" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"leaderboardShortCode" : "",
"scriptData" : { },
"social" : false
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AroundMeLeaderboardRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetCustomIdFilter(customIdFilter)
.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
.SetEntryCount(entryCount)
.SetFriendIds(friendIds)
.SetIncludeFirst(includeFirst)
.SetIncludeLast(includeLast)
.SetInverseSocial(inverseSocial)
.SetLeaderboardShortCode(leaderboardShortCode)
.SetSocial(social)
.SetTeamIds(teamIds)
.SetTeamTypes(teamTypes)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSEnumerable<var> data = response.Data;
GSEnumerable<var> first = response.First;
GSEnumerable<var> last = response.Last;
string leaderboardShortCode = response.LeaderboardShortCode;
GSData scriptData = response.ScriptData;
bool? social = response.Social;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAroundMeLeaderboardRequest()
.setChallengeInstanceId(challengeInstanceId)
.setCustomIdFilter(customIdFilter)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.AroundMeLeaderboardResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var data:Vector.<LeaderboardData> = response.getData();
var first:Vector.<LeaderboardData> = response.getFirst();
var last:Vector.<LeaderboardData> = response.getLast();
var leaderboardShortCode:String = response.getLeaderboardShortCode();
var scriptData:ScriptData = response.getScriptData();
var social:Boolean = response.getSocial();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAroundMeLeaderboardRequest* request = [[GSAroundMeLeaderboardRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setCustomIdFilter:customIdFilter;
[request setDontErrorOnNotSocial:dontErrorOnNotSocial;
[request setEntryCount:entryCount;
[request setFriendIds:friendIds;
[request setIncludeFirst:includeFirst;
[request setIncludeLast:includeLast;
[request setInverseSocial:inverseSocial;
[request setLeaderboardShortCode:leaderboardShortCode;
[request setSocial:social;
[request setTeamIds:teamIds;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSAroundMeLeaderboardResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSArray* data = [response getData];
NSArray* first = [response getFirst];
NSArray* last = [response getLast];
NSString* leaderboardShortCode = [response getLeaderboardShortCode];
NSDictionary* scriptData = [response getScriptData];
BOOL social = [response getSocial];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AroundMeLeaderboardRequest_Response(GS& gsInstance, const AroundMeLeaderboardResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
gsstl:vector<Types::LeaderboardData*> data = response.getData();
gsstl:vector<Types::LeaderboardData*> first = response.getFirst();
gsstl:vector<Types::LeaderboardData*> last = response.getLast();
gsstl::string leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
Optional::t_BoolOptional social = response.getSocial();
}
......
AroundMeLeaderboardRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetCustomIdFilter(customIdFilter)
request.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
request.SetEntryCount(entryCount)
request.SetFriendIds(friendIds)
request.SetIncludeFirst(includeFirst)
request.SetIncludeLast(includeLast)
request.SetInverseSocial(inverseSocial)
request.SetLeaderboardShortCode(leaderboardShortCode)
request.SetSocial(social)
request.SetTeamIds(teamIds)
request.SetTeamTypes(teamTypes)
request.Send(AroundMeLeaderboardRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AroundMeLeaderboardRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AroundMeLeaderboardResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAroundMeLeaderboardRequest()
.setChallengeInstanceId(challengeInstanceId)
.setCustomIdFilter(customIdFilter)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(new GSEventListener<AroundMeLeaderboardResponse>() {
@Override
public void onEvent(AroundMeLeaderboardResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
List<LeaderboardData> data = response.getData();
List<LeaderboardData> first = response.getFirst();
List<LeaderboardData> last = response.getLast();
String leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
Boolean social = response.getSocial();
}
});
var request = new SparkRequests.AroundMeLeaderboardRequest();
request.challengeInstanceId = ...;
request.customIdFilter = ...;
request.dontErrorOnNotSocial = ...;
request.entryCount = ...;
request.friendIds = ...;
request.includeFirst = ...;
request.includeLast = ...;
request.inverseSocial = ...;
request.leaderboardShortCode = ...;
request.social = ...;
request.teamIds = ...;
request.teamTypes = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
var social = response.social;
var request = RTSession.newRequest().createAroundMeLeaderboardRequest();
request.setChallengeInstanceId(...);
request.setCustomIdFilter(...);
request.setDontErrorOnNotSocial(...);
request.setEntryCount(...);
request.setFriendIds(...);
request.setIncludeFirst(...);
request.setIncludeLast(...);
request.setInverseSocial(...);
request.setLeaderboardShortCode(...);
request.setSocial(...);
request.setTeamIds(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
var social = response.social;
});
Returns leaderboard data that is adjacent to the currently signed in player’s position within the given leaderboard.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | No | string | The challenge instance to get the leaderboard data for |
customIdFilter | No | JSON | An optional filter on the customIds. |
dontErrorOnNotSocial | No | boolean | The default behaviour on a social request is to error if the player has no friends (NOTSOCIAL). Set this flag to suppress that error and return the player’s leaderboard entry instead. |
entryCount | Yes | number | The number of items to return in a page (default=50) |
friendIds | No | string[] | A friend id or an array of friend ids to use instead of the player’s social friends |
includeFirst | No | number | Number of entries to include from head of the list |
includeLast | No | number | Number of entries to include from tail of the list |
inverseSocial | No | boolean | Returns the leaderboard excluding the player’s social friends |
leaderboardShortCode | No | string | The short code of the leaderboard |
social | No | boolean | If True returns a leaderboard of the player’s social friends |
teamIds | No | string[] | The IDs of the teams you are interested in |
teamTypes | No | string[] | The type of team you are interested in |
Response Parameters
A response containing leaderboard data around the current player
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The leaderboard’s challenge id |
data | LeaderboardData[] | The leaderboard data |
first | LeaderboardData[] | The first item in the leaderboard data |
last | LeaderboardData[] | The last item in the leaderboard data |
leaderboardShortCode | string | The leaderboard short code |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
social | boolean | True if the response contains a social leaderboard’s data |
Error Codes
Key | Value | Description |
---|---|---|
leaderboardShortCode|challengeInstanceId | ONLY_ONE | Both shortCode and challengeInstanceId were supplied, only one should be supplied |
leaderboardShortCode|challengeInstanceId | REQUIRED | Both shortCode and challengeInstanceId were missing |
leaderboardShortCode | INVALID | The shortCode does not match a configured leaderboard |
challengeInstanceId | NO_LEADERBOARD | The challengeInstanceId maps to a challenge without a leaderboard configured |
challengeInstanceId | INVALID | The challengeInstanceId supplied did not match a challenge related to the current play |
challengeInstanceVersion | INVALID | The challengeInstance predates support for this request type |
GetLeaderboardEntriesRequest
{
"@class" : ".GetLeaderboardEntriesRequest",
"challenges" : [ "" ],
"inverseSocial" : false,
"leaderboards" : [ "" ],
"player" : "",
"social" : false,
"teamTypes" : [ "" ]
}
{
"@class" : ".GetLeaderboardEntriesResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetLeaderboardEntriesRequest()
.SetChallenges(challenges)
.SetInverseSocial(inverseSocial)
.SetLeaderboards(leaderboards)
.SetPlayer(player)
.SetSocial(social)
.SetTeamTypes(teamTypes)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetLeaderboardEntriesRequest()
.setChallenges(challenges)
.setInverseSocial(inverseSocial)
.setLeaderboards(leaderboards)
.setPlayer(player)
.setSocial(social)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.GetLeaderboardEntriesResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetLeaderboardEntriesRequest* request = [[GSGetLeaderboardEntriesRequest alloc] init];
[request setChallenges:challenges;
[request setInverseSocial:inverseSocial;
[request setLeaderboards:leaderboards;
[request setPlayer:player;
[request setSocial:social;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSGetLeaderboardEntriesResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetLeaderboardEntriesRequest_Response(GS& gsInstance, const GetLeaderboardEntriesResponse& response) {
GSData scriptData = response.getScriptData();
}
......
GetLeaderboardEntriesRequest request(gsInstance);
request.SetChallenges(challenges)
request.SetInverseSocial(inverseSocial)
request.SetLeaderboards(leaderboards)
request.SetPlayer(player)
request.SetSocial(social)
request.SetTeamTypes(teamTypes)
request.Send(GetLeaderboardEntriesRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetLeaderboardEntriesRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetLeaderboardEntriesResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetLeaderboardEntriesRequest()
.setChallenges(challenges)
.setInverseSocial(inverseSocial)
.setLeaderboards(leaderboards)
.setPlayer(player)
.setSocial(social)
.setTeamTypes(teamTypes)
.send(new GSEventListener<GetLeaderboardEntriesResponse>() {
@Override
public void onEvent(GetLeaderboardEntriesResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.GetLeaderboardEntriesRequest();
request.challenges = ...;
request.inverseSocial = ...;
request.leaderboards = ...;
request.player = ...;
request.social = ...;
request.teamTypes = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createGetLeaderboardEntriesRequest();
request.setChallenges(...);
request.setInverseSocial(...);
request.setLeaderboards(...);
request.setPlayer(...);
request.setSocial(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Get the leaderboard entry data for the current player or a given player.
For each leaderboard it returns the hichest score the player has
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challenges | No | string[] | The challenge leaderboards to return entries for |
inverseSocial | No | boolean | Returns the leaderboard excluding the player’s social friends |
leaderboards | No | string[] | The list of leaderboards shortcodes |
player | No | string | The player id. Leave out to use the current player id |
social | No | boolean | Set to true to include the player’s game friends |
teamTypes | No | string[] | The types of team to apply this request to |
Response Parameters
A response containing leaderboard entry data for a given player. Example response:
{"HS": {"userId":"537f08e1e4b01fdedfa52c49","SCORE": 123,"city":"York","country":"GB","userName":"","when":"2014-07-17T12:18Z","rank": 1 }
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
LeaderboardDataRequest
{
"@class" : ".LeaderboardDataRequest",
"challengeInstanceId" : "",
"dontErrorOnNotSocial" : false,
"entryCount" : 0,
"friendIds" : [ "" ],
"includeFirst" : 0,
"includeLast" : 0,
"inverseSocial" : false,
"leaderboardShortCode" : "",
"offset" : 0,
"social" : false,
"teamIds" : [ "" ],
"teamTypes" : [ "" ]
}
{
"@class" : ".LeaderboardDataResponse",
"challengeInstanceId" : "",
"data" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"first" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"last" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"leaderboardShortCode" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new LeaderboardDataRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
.SetEntryCount(entryCount)
.SetFriendIds(friendIds)
.SetIncludeFirst(includeFirst)
.SetIncludeLast(includeLast)
.SetInverseSocial(inverseSocial)
.SetLeaderboardShortCode(leaderboardShortCode)
.SetOffset(offset)
.SetSocial(social)
.SetTeamIds(teamIds)
.SetTeamTypes(teamTypes)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSEnumerable<var> data = response.Data;
GSEnumerable<var> first = response.First;
GSEnumerable<var> last = response.Last;
string leaderboardShortCode = response.LeaderboardShortCode;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createLeaderboardDataRequest()
.setChallengeInstanceId(challengeInstanceId)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setOffset(offset)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.LeaderboardDataResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var data:Vector.<LeaderboardData> = response.getData();
var first:Vector.<LeaderboardData> = response.getFirst();
var last:Vector.<LeaderboardData> = response.getLast();
var leaderboardShortCode:String = response.getLeaderboardShortCode();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSLeaderboardDataRequest* request = [[GSLeaderboardDataRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setDontErrorOnNotSocial:dontErrorOnNotSocial;
[request setEntryCount:entryCount;
[request setFriendIds:friendIds;
[request setIncludeFirst:includeFirst;
[request setIncludeLast:includeLast;
[request setInverseSocial:inverseSocial;
[request setLeaderboardShortCode:leaderboardShortCode;
[request setOffset:offset;
[request setSocial:social;
[request setTeamIds:teamIds;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSLeaderboardDataResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSArray* data = [response getData];
NSArray* first = [response getFirst];
NSArray* last = [response getLast];
NSString* leaderboardShortCode = [response getLeaderboardShortCode];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void LeaderboardDataRequest_Response(GS& gsInstance, const LeaderboardDataResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
gsstl:vector<Types::LeaderboardData*> data = response.getData();
gsstl:vector<Types::LeaderboardData*> first = response.getFirst();
gsstl:vector<Types::LeaderboardData*> last = response.getLast();
gsstl::string leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
}
......
LeaderboardDataRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
request.SetEntryCount(entryCount)
request.SetFriendIds(friendIds)
request.SetIncludeFirst(includeFirst)
request.SetIncludeLast(includeLast)
request.SetInverseSocial(inverseSocial)
request.SetLeaderboardShortCode(leaderboardShortCode)
request.SetOffset(offset)
request.SetSocial(social)
request.SetTeamIds(teamIds)
request.SetTeamTypes(teamTypes)
request.Send(LeaderboardDataRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LeaderboardDataRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LeaderboardDataResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createLeaderboardDataRequest()
.setChallengeInstanceId(challengeInstanceId)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setOffset(offset)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(new GSEventListener<LeaderboardDataResponse>() {
@Override
public void onEvent(LeaderboardDataResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
List<LeaderboardData> data = response.getData();
List<LeaderboardData> first = response.getFirst();
List<LeaderboardData> last = response.getLast();
String leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.LeaderboardDataRequest();
request.challengeInstanceId = ...;
request.dontErrorOnNotSocial = ...;
request.entryCount = ...;
request.friendIds = ...;
request.includeFirst = ...;
request.includeLast = ...;
request.inverseSocial = ...;
request.leaderboardShortCode = ...;
request.offset = ...;
request.social = ...;
request.teamIds = ...;
request.teamTypes = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createLeaderboardDataRequest();
request.setChallengeInstanceId(...);
request.setDontErrorOnNotSocial(...);
request.setEntryCount(...);
request.setFriendIds(...);
request.setIncludeFirst(...);
request.setIncludeLast(...);
request.setInverseSocial(...);
request.setLeaderboardShortCode(...);
request.setOffset(...);
request.setSocial(...);
request.setTeamIds(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
});
Returns the top data for either the specified global leaderboard or the specified challenges leaderboard. The data is sorted as defined in the rules specified in the leaderboard configuration.
The response contains the top of the leaderboard, and returns the number of entries as defined in the entryCount parameter.
If a shortCode is supplied, the response will contain the global leaderboard data. If a challengeInstanceId is supplied, the response will contain the leaderboard data for the challenge.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | No | string | The challenge instance to get the leaderboard data for |
dontErrorOnNotSocial | No | boolean | The default behaviour on a social request is to error if the player has no friends (NOTSOCIAL). Set this flag to suppress that error and return the player’s leaderboard entry instead. |
entryCount | Yes | number | The number of items to return in a page (default=50) |
friendIds | No | string[] | A friend id or an array of friend ids to use instead of the player’s social friends |
includeFirst | No | number | Number of entries to include from head of the list |
includeLast | No | number | Number of entries to include from tail of the list |
inverseSocial | No | boolean | Returns the leaderboard excluding the player’s social friends |
leaderboardShortCode | No | string | The short code of the leaderboard |
offset | No | number | The offset into the set of leaderboards returned |
social | No | boolean | If True returns a leaderboard of the player’s social friends |
teamIds | No | string[] | The IDs of the teams you are interested in |
teamTypes | No | string[] | The type of team you are interested in |
Response Parameters
A response containing leaderboard data
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The leaderboard’s challenge id |
data | LeaderboardData[] | The leaderboard data |
first | LeaderboardData[] | The first item in the leaderboard data |
last | LeaderboardData[] | The last item in the leaderboard data |
leaderboardShortCode | string | The leaderboard short code |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
leaderboardShortCode|challengeInstanceId | ONLY_ONE | Both shortCode and challengeInstanceId were supplied, only one should be supplied |
leaderboardShortCode|challengeInstanceId | REQUIRED | Both shortCode and challengeInstanceId were missing |
leaderboardShortCode | INVALID | The shortCode does not match a configured leaderboard |
currentUser | NOTSOCIAL | The current player does not have any game friends |
challengeInstanceId | NO_LEADERBOARD | The challengeInstanceId maps to a challenge without a leaderboard configured |
challengeInstanceId | INVALID | The challengeInstanceId supplied did not match a challenge related to the current play |
LeaderboardsEntriesRequest
{
"@class" : ".LeaderboardsEntriesRequest",
"challenges" : [ "" ],
"inverseSocial" : false,
"leaderboards" : [ "" ],
"player" : "",
"social" : false,
"teamTypes" : [ "" ]
}
{
"@class" : ".LeaderboardsEntriesResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new LeaderboardsEntriesRequest()
.SetChallenges(challenges)
.SetInverseSocial(inverseSocial)
.SetLeaderboards(leaderboards)
.SetPlayer(player)
.SetSocial(social)
.SetTeamTypes(teamTypes)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createLeaderboardsEntriesRequest()
.setChallenges(challenges)
.setInverseSocial(inverseSocial)
.setLeaderboards(leaderboards)
.setPlayer(player)
.setSocial(social)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.LeaderboardsEntriesResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSLeaderboardsEntriesRequest* request = [[GSLeaderboardsEntriesRequest alloc] init];
[request setChallenges:challenges;
[request setInverseSocial:inverseSocial;
[request setLeaderboards:leaderboards;
[request setPlayer:player;
[request setSocial:social;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSLeaderboardsEntriesResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void LeaderboardsEntriesRequest_Response(GS& gsInstance, const LeaderboardsEntriesResponse& response) {
GSData scriptData = response.getScriptData();
}
......
LeaderboardsEntriesRequest request(gsInstance);
request.SetChallenges(challenges)
request.SetInverseSocial(inverseSocial)
request.SetLeaderboards(leaderboards)
request.SetPlayer(player)
request.SetSocial(social)
request.SetTeamTypes(teamTypes)
request.Send(LeaderboardsEntriesRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LeaderboardsEntriesRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LeaderboardsEntriesResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createLeaderboardsEntriesRequest()
.setChallenges(challenges)
.setInverseSocial(inverseSocial)
.setLeaderboards(leaderboards)
.setPlayer(player)
.setSocial(social)
.setTeamTypes(teamTypes)
.send(new GSEventListener<LeaderboardsEntriesResponse>() {
@Override
public void onEvent(LeaderboardsEntriesResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.LeaderboardsEntriesRequest();
request.challenges = ...;
request.inverseSocial = ...;
request.leaderboards = ...;
request.player = ...;
request.social = ...;
request.teamTypes = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createLeaderboardsEntriesRequest();
request.setChallenges(...);
request.setInverseSocial(...);
request.setLeaderboards(...);
request.setPlayer(...);
request.setSocial(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Get the leaderboard entry data for the current player or a given player.
For each leaderboard it returns the array of leaderboard entries that the player has.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challenges | No | string[] | The challenge leaderboards to return entries for |
inverseSocial | No | boolean | Returns the leaderboard excluding the player’s social friends |
leaderboards | No | string[] | The list of leaderboards shortcodes |
player | No | string | The player id. Leave out to use the current player id |
social | No | boolean | Set to true to include the player’s game friends |
teamTypes | No | string[] | The types of team to apply this request to |
Response Parameters
A response containing leaderboard entry data for a given player. The response will contain one key for every leaderboard in the result. Example response:
{"HS": [{"userId":"537f08e1e4b01fdedfa52c49","SCORE": 123,"city":"York","country":"GB","userName":"","when":"2014-07-17T12:18Z","rank": 1 }]}
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListLeaderboardsRequest
{
"@class" : ".ListLeaderboardsRequest"
}
{
"@class" : ".ListLeaderboardsResponse",
"leaderboards" : [ {
"description" : "",
"name" : "",
"propertySet" : { },
"shortCode" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListLeaderboardsRequest()
.Send((response) => {
GSEnumerable<var> leaderboards = response.Leaderboards;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListLeaderboardsRequest()
.send(function(response:com.gamesparks.api.responses.ListLeaderboardsResponse):void {
var leaderboards:Vector.<Leaderboard> = response.getLeaderboards();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListLeaderboardsRequest* request = [[GSListLeaderboardsRequest alloc] init];
[request setCallback:^ (GSListLeaderboardsResponse* response) {
NSArray* leaderboards = [response getLeaderboards];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListLeaderboardsRequest_Response(GS& gsInstance, const ListLeaderboardsResponse& response) {
gsstl:vector<Types::Leaderboard*> leaderboards = response.getLeaderboards();
GSData scriptData = response.getScriptData();
}
......
ListLeaderboardsRequest request(gsInstance);
request.Send(ListLeaderboardsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListLeaderboardsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListLeaderboardsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListLeaderboardsRequest()
.send(new GSEventListener<ListLeaderboardsResponse>() {
@Override
public void onEvent(ListLeaderboardsResponse response) {
List<Leaderboard> leaderboards = response.getLeaderboards();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListLeaderboardsRequest();
var response = request.Send();
var leaderboards = response.leaderboards;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListLeaderboardsRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var leaderboards = response.leaderboards;
var scriptData = response.scriptData;
});
Returns a list of all leaderboards configured in the game.
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing a list of all leaderboards configured in the game.
Parameter | Type | Description |
---|---|---|
leaderboards | Leaderboard[] | A list of JSON object containing leaderboard meta data |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
SocialLeaderboardDataRequest
{
"@class" : ".SocialLeaderboardDataRequest",
"challengeInstanceId" : "",
"dontErrorOnNotSocial" : false,
"entryCount" : 0,
"friendIds" : [ "" ],
"includeFirst" : 0,
"includeLast" : 0,
"inverseSocial" : false,
"leaderboardShortCode" : "",
"offset" : 0,
"social" : false,
"teamIds" : [ "" ],
"teamTypes" : [ "" ]
}
{
"@class" : ".LeaderboardDataResponse",
"challengeInstanceId" : "",
"data" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"first" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"last" : [ {
"city" : "",
"country" : "",
"externalIds" : { },
"rank" : 0,
"userId" : "",
"userName" : "",
"when" : ""
} ],
"leaderboardShortCode" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SocialLeaderboardDataRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
.SetEntryCount(entryCount)
.SetFriendIds(friendIds)
.SetIncludeFirst(includeFirst)
.SetIncludeLast(includeLast)
.SetInverseSocial(inverseSocial)
.SetLeaderboardShortCode(leaderboardShortCode)
.SetOffset(offset)
.SetSocial(social)
.SetTeamIds(teamIds)
.SetTeamTypes(teamTypes)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSEnumerable<var> data = response.Data;
GSEnumerable<var> first = response.First;
GSEnumerable<var> last = response.Last;
string leaderboardShortCode = response.LeaderboardShortCode;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSocialLeaderboardDataRequest()
.setChallengeInstanceId(challengeInstanceId)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setOffset(offset)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.LeaderboardDataResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var data:Vector.<LeaderboardData> = response.getData();
var first:Vector.<LeaderboardData> = response.getFirst();
var last:Vector.<LeaderboardData> = response.getLast();
var leaderboardShortCode:String = response.getLeaderboardShortCode();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSocialLeaderboardDataRequest* request = [[GSSocialLeaderboardDataRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setDontErrorOnNotSocial:dontErrorOnNotSocial;
[request setEntryCount:entryCount;
[request setFriendIds:friendIds;
[request setIncludeFirst:includeFirst;
[request setIncludeLast:includeLast;
[request setInverseSocial:inverseSocial;
[request setLeaderboardShortCode:leaderboardShortCode;
[request setOffset:offset;
[request setSocial:social;
[request setTeamIds:teamIds;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSLeaderboardDataResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSArray* data = [response getData];
NSArray* first = [response getFirst];
NSArray* last = [response getLast];
NSString* leaderboardShortCode = [response getLeaderboardShortCode];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SocialLeaderboardDataRequest_Response(GS& gsInstance, const LeaderboardDataResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
gsstl:vector<Types::LeaderboardData*> data = response.getData();
gsstl:vector<Types::LeaderboardData*> first = response.getFirst();
gsstl:vector<Types::LeaderboardData*> last = response.getLast();
gsstl::string leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
}
......
SocialLeaderboardDataRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetDontErrorOnNotSocial(dontErrorOnNotSocial)
request.SetEntryCount(entryCount)
request.SetFriendIds(friendIds)
request.SetIncludeFirst(includeFirst)
request.SetIncludeLast(includeLast)
request.SetInverseSocial(inverseSocial)
request.SetLeaderboardShortCode(leaderboardShortCode)
request.SetOffset(offset)
request.SetSocial(social)
request.SetTeamIds(teamIds)
request.SetTeamTypes(teamTypes)
request.Send(SocialLeaderboardDataRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SocialLeaderboardDataRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LeaderboardDataResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSocialLeaderboardDataRequest()
.setChallengeInstanceId(challengeInstanceId)
.setDontErrorOnNotSocial(dontErrorOnNotSocial)
.setEntryCount(entryCount)
.setFriendIds(friendIds)
.setIncludeFirst(includeFirst)
.setIncludeLast(includeLast)
.setInverseSocial(inverseSocial)
.setLeaderboardShortCode(leaderboardShortCode)
.setOffset(offset)
.setSocial(social)
.setTeamIds(teamIds)
.setTeamTypes(teamTypes)
.send(new GSEventListener<LeaderboardDataResponse>() {
@Override
public void onEvent(LeaderboardDataResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
List<LeaderboardData> data = response.getData();
List<LeaderboardData> first = response.getFirst();
List<LeaderboardData> last = response.getLast();
String leaderboardShortCode = response.getLeaderboardShortCode();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.SocialLeaderboardDataRequest();
request.challengeInstanceId = ...;
request.dontErrorOnNotSocial = ...;
request.entryCount = ...;
request.friendIds = ...;
request.includeFirst = ...;
request.includeLast = ...;
request.inverseSocial = ...;
request.leaderboardShortCode = ...;
request.offset = ...;
request.social = ...;
request.teamIds = ...;
request.teamTypes = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createSocialLeaderboardDataRequest();
request.setChallengeInstanceId(...);
request.setDontErrorOnNotSocial(...);
request.setEntryCount(...);
request.setFriendIds(...);
request.setIncludeFirst(...);
request.setIncludeLast(...);
request.setInverseSocial(...);
request.setLeaderboardShortCode(...);
request.setOffset(...);
request.setSocial(...);
request.setTeamIds(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var data = response.data;
var first = response.first;
var last = response.last;
var leaderboardShortCode = response.leaderboardShortCode;
var scriptData = response.scriptData;
});
Returns leaderboard data that only contains entries of players that are game friends with the current player.
The GameSparks platform will attempt to return players both ahead and behind the current player, where data is available.
The entry count defines how many player should be returned both ahead and behind. The numer of results may vary if there are not enough friends either ahead or behind.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | No | string | The challenge instance to get the leaderboard data for |
dontErrorOnNotSocial | No | boolean | The default behaviour on a social request is to error if the player has no friends (NOTSOCIAL). Set this flag to suppress that error and return the player’s leaderboard entry instead. |
entryCount | Yes | number | The number of items to return in a page (default=50) |
friendIds | No | string[] | A friend id or an array of friend ids to use instead of the player’s social friends |
includeFirst | No | number | Number of entries to include from head of the list |
includeLast | No | number | Number of entries to include from tail of the list |
inverseSocial | No | boolean | Returns the leaderboard excluding the player’s social friends |
leaderboardShortCode | No | string | The short code of the leaderboard |
offset | No | number | The offset into the set of leaderboards returned |
social | No | boolean | If True returns a leaderboard of the player’s social friends |
teamIds | No | string[] | The IDs of the teams you are interested in |
teamTypes | No | string[] | The type of team you are interested in |
Response Parameters
A response containing leaderboard data
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The leaderboard’s challenge id |
data | LeaderboardData[] | The leaderboard data |
first | LeaderboardData[] | The first item in the leaderboard data |
last | LeaderboardData[] | The last item in the leaderboard data |
leaderboardShortCode | string | The leaderboard short code |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
leaderboardShortCode|challengeInstanceId | ONLY_ONE | Both shortCode and challengeInstanceId were supplied, only one should be supplied |
leaderboardShortCode|challengeInstanceId | REQUIRED | Both shortCode and challengeInstanceId were missing |
leaderboardShortCode | INVALID | The shortCode does not match a configured leaderboard |
currentUser | NOTSOCIAL | The current player does not have any game friends |
challengeInstanceId | NO_LEADERBOARD | The challengeInstanceId maps to a challenge without a leaderboard configured |
challengeInstanceId | INVALID | The challengeInstanceId supplied did not match a challenge related to the current play |
Misc
GetDownloadableRequest
{
"@class" : ".GetDownloadableRequest",
"shortCode" : ""
}
{
"@class" : ".GetDownloadableResponse",
"lastModified" : "2018-07-11T14:02Z",
"scriptData" : { },
"shortCode" : "",
"size" : 0,
"url" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetDownloadableRequest()
.SetShortCode(shortCode)
.Send((response) => {
DateTime? lastModified = response.LastModified;
GSData scriptData = response.ScriptData;
string shortCode = response.ShortCode;
var size = response.Size;
string url = response.Url;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetDownloadableRequest()
.setShortCode(shortCode)
.send(function(response:com.gamesparks.api.responses.GetDownloadableResponse):void {
var lastModified:Date = response.getLastModified();
var scriptData:ScriptData = response.getScriptData();
var shortCode:String = response.getShortCode();
var size:Number = response.getSize();
var url:String = response.getUrl();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetDownloadableRequest* request = [[GSGetDownloadableRequest alloc] init];
[request setShortCode:shortCode;
[request setCallback:^ (GSGetDownloadableResponse* response) {
NSDate* lastModified = [response getLastModified];
NSDictionary* scriptData = [response getScriptData];
NSString* shortCode = [response getShortCode];
NSNumber* size = [response getSize];
NSString* url = [response getUrl];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetDownloadableRequest_Response(GS& gsInstance, const GetDownloadableResponse& response) {
GSDateTime::t_Optional lastModified = response.getLastModified();
GSData scriptData = response.getScriptData();
gsstl::string shortCode = response.getShortCode();
Optional::t_LongOptional size = response.getSize();
gsstl::string url = response.getUrl();
}
......
GetDownloadableRequest request(gsInstance);
request.SetShortCode(shortCode)
request.Send(GetDownloadableRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetDownloadableRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetDownloadableResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetDownloadableRequest()
.setShortCode(shortCode)
.send(new GSEventListener<GetDownloadableResponse>() {
@Override
public void onEvent(GetDownloadableResponse response) {
Date lastModified = response.getLastModified();
GSData scriptData = response.getScriptData();
String shortCode = response.getShortCode();
Long size = response.getSize();
String url = response.getUrl();
}
});
var request = new SparkRequests.GetDownloadableRequest();
request.shortCode = ...;
var response = request.Send();
var lastModified = response.lastModified;
var scriptData = response.scriptData;
var shortCode = response.shortCode;
var size = response.size;
var url = response.url;
var request = RTSession.newRequest().createGetDownloadableRequest();
request.setShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var lastModified = response.lastModified;
var scriptData = response.scriptData;
var shortCode = response.shortCode;
var size = response.size;
var url = response.url;
});
Returns a secure, time sensitive url to allow the game to download a piece of downloadable content stored in the GameSparks platform.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
shortCode | Yes | string | The short code of the Downloadable item |
Response Parameters
A response containing the download URL for a downloadable item
Parameter | Type | Description |
---|---|---|
lastModified | date | The date when the downloadable item was last modified |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
shortCode | string | The short code of the item |
size | number | The size of the item in bytes |
url | string | The download URL |
Error Codes
Key | Value | Description |
---|---|---|
shortCode | INVALID | The short code does not match any Downloadable shortCode |
GetPropertyRequest
{
"@class" : ".GetPropertyRequest",
"propertyShortCode" : ""
}
{
"@class" : ".GetPropertyResponse",
"property" : { },
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetPropertyRequest()
.SetPropertyShortCode(propertyShortCode)
.Send((response) => {
GSData property = response.Property;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetPropertyRequest()
.setPropertyShortCode(propertyShortCode)
.send(function(response:com.gamesparks.api.responses.GetPropertyResponse):void {
var property:Object = response.getProperty();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetPropertyRequest* request = [[GSGetPropertyRequest alloc] init];
[request setPropertyShortCode:propertyShortCode;
[request setCallback:^ (GSGetPropertyResponse* response) {
NSDictionary* property = [response getProperty];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetPropertyRequest_Response(GS& gsInstance, const GetPropertyResponse& response) {
GSData property = response.getProperty();
GSData scriptData = response.getScriptData();
}
......
GetPropertyRequest request(gsInstance);
request.SetPropertyShortCode(propertyShortCode)
request.Send(GetPropertyRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetPropertyRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetPropertyResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetPropertyRequest()
.setPropertyShortCode(propertyShortCode)
.send(new GSEventListener<GetPropertyResponse>() {
@Override
public void onEvent(GetPropertyResponse response) {
GSData property = response.getProperty();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.GetPropertyRequest();
request.propertyShortCode = ...;
var response = request.Send();
var property = response.property;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createGetPropertyRequest();
request.setPropertyShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var property = response.property;
var scriptData = response.scriptData;
});
Get the property for the given short Code.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
propertyShortCode | Yes | string | The shortCode of the property to return. |
Response Parameters
A response containing the requested property
Parameter | Type | Description |
---|---|---|
property | JSON | The property value |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
property | NOT_FOUND | No property with given shortCode could be found. |
GetPropertySetRequest
{
"@class" : ".GetPropertySetRequest",
"propertySetShortCode" : ""
}
{
"@class" : ".GetPropertySetResponse",
"propertySet" : { },
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetPropertySetRequest()
.SetPropertySetShortCode(propertySetShortCode)
.Send((response) => {
GSData propertySet = response.PropertySet;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetPropertySetRequest()
.setPropertySetShortCode(propertySetShortCode)
.send(function(response:com.gamesparks.api.responses.GetPropertySetResponse):void {
var propertySet:Object = response.getPropertySet();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetPropertySetRequest* request = [[GSGetPropertySetRequest alloc] init];
[request setPropertySetShortCode:propertySetShortCode;
[request setCallback:^ (GSGetPropertySetResponse* response) {
NSDictionary* propertySet = [response getPropertySet];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetPropertySetRequest_Response(GS& gsInstance, const GetPropertySetResponse& response) {
GSData propertySet = response.getPropertySet();
GSData scriptData = response.getScriptData();
}
......
GetPropertySetRequest request(gsInstance);
request.SetPropertySetShortCode(propertySetShortCode)
request.Send(GetPropertySetRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetPropertySetRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetPropertySetResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetPropertySetRequest()
.setPropertySetShortCode(propertySetShortCode)
.send(new GSEventListener<GetPropertySetResponse>() {
@Override
public void onEvent(GetPropertySetResponse response) {
GSData propertySet = response.getPropertySet();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.GetPropertySetRequest();
request.propertySetShortCode = ...;
var response = request.Send();
var propertySet = response.propertySet;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createGetPropertySetRequest();
request.setPropertySetShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var propertySet = response.propertySet;
var scriptData = response.scriptData;
});
Get the property set for the given short Code.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
propertySetShortCode | Yes | string | The shortCode of the property set to return. |
Response Parameters
A response containing the requested property set
Parameter | Type | Description |
---|---|---|
propertySet | JSON | The property set |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
propertySet | NOT_FOUND | No propertySet with given shortCode could be found. |
GetUploadUrlRequest
{
"@class" : ".GetUploadUrlRequest",
"uploadData" : [ { } ]
}
{
"@class" : ".GetUploadUrlResponse",
"scriptData" : { },
"url" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetUploadUrlRequest()
.SetUploadData(uploadData)
.Send((response) => {
GSData scriptData = response.ScriptData;
string url = response.Url;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetUploadUrlRequest()
.setUploadData(uploadData)
.send(function(response:com.gamesparks.api.responses.GetUploadUrlResponse):void {
var scriptData:ScriptData = response.getScriptData();
var url:String = response.getUrl();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetUploadUrlRequest* request = [[GSGetUploadUrlRequest alloc] init];
[request setUploadData:uploadData;
[request setCallback:^ (GSGetUploadUrlResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSString* url = [response getUrl];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetUploadUrlRequest_Response(GS& gsInstance, const GetUploadUrlResponse& response) {
GSData scriptData = response.getScriptData();
gsstl::string url = response.getUrl();
}
......
GetUploadUrlRequest request(gsInstance);
request.SetUploadData(uploadData)
request.Send(GetUploadUrlRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetUploadUrlRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetUploadUrlResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetUploadUrlRequest()
.setUploadData(uploadData)
.send(new GSEventListener<GetUploadUrlResponse>() {
@Override
public void onEvent(GetUploadUrlResponse response) {
GSData scriptData = response.getScriptData();
String url = response.getUrl();
}
});
var request = new SparkRequests.GetUploadUrlRequest();
request.uploadData = ...;
var response = request.Send();
var scriptData = response.scriptData;
var url = response.url;
var request = RTSession.newRequest().createGetUploadUrlRequest();
request.setUploadData(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var url = response.url;
});
Returns a secure, time sensitive URL to allow the game to upload a piece of player content to the GameSparks platform.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
uploadData | No | JSON[] | Optional meta data which is stored against the player’s uploaded content |
Response Parameters
A response containing a time sensitive URL to allow the game to upload a piece of player content to the GameSparks platform
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
url | string | The time sensitive upload URL |
GetUploadedRequest
{
"@class" : ".GetUploadedRequest",
"uploadId" : ""
}
{
"@class" : ".GetUploadedResponse",
"scriptData" : { },
"size" : 0,
"url" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetUploadedRequest()
.SetUploadId(uploadId)
.Send((response) => {
GSData scriptData = response.ScriptData;
var size = response.Size;
string url = response.Url;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetUploadedRequest()
.setUploadId(uploadId)
.send(function(response:com.gamesparks.api.responses.GetUploadedResponse):void {
var scriptData:ScriptData = response.getScriptData();
var size:Number = response.getSize();
var url:String = response.getUrl();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetUploadedRequest* request = [[GSGetUploadedRequest alloc] init];
[request setUploadId:uploadId;
[request setCallback:^ (GSGetUploadedResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSNumber* size = [response getSize];
NSString* url = [response getUrl];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetUploadedRequest_Response(GS& gsInstance, const GetUploadedResponse& response) {
GSData scriptData = response.getScriptData();
Optional::t_LongOptional size = response.getSize();
gsstl::string url = response.getUrl();
}
......
GetUploadedRequest request(gsInstance);
request.SetUploadId(uploadId)
request.Send(GetUploadedRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetUploadedRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetUploadedResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetUploadedRequest()
.setUploadId(uploadId)
.send(new GSEventListener<GetUploadedResponse>() {
@Override
public void onEvent(GetUploadedResponse response) {
GSData scriptData = response.getScriptData();
Long size = response.getSize();
String url = response.getUrl();
}
});
var request = new SparkRequests.GetUploadedRequest();
request.uploadId = ...;
var response = request.Send();
var scriptData = response.scriptData;
var size = response.size;
var url = response.url;
var request = RTSession.newRequest().createGetUploadedRequest();
request.setUploadId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var size = response.size;
var url = response.url;
});
Returns a secure, time sensitive URL to a piece of content that was previously uploaded to the GameSparks platform by a player.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
uploadId | No | string | The system generated id of the uploaded item |
Response Parameters
A reponse containing a time sensitive URL to a piece of content that was previously uploaded to the GameSparks platform by a player.
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
size | number | The size of the file in bytes |
url | string | A time sensitive URL to a piece of content |
Error Codes
Key | Value | Description |
---|---|---|
uploadId | INVALID | The upload id was invalid |
PushRegistrationRequest
{
"@class" : ".PushRegistrationRequest",
"deviceOS" : "",
"pushId" : ""
}
{
"@class" : ".PushRegistrationResponse",
"registrationId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new PushRegistrationRequest()
.SetDeviceOS(deviceOS)
.SetPushId(pushId)
.Send((response) => {
string registrationId = response.RegistrationId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createPushRegistrationRequest()
.setDeviceOS(deviceOS)
.setPushId(pushId)
.send(function(response:com.gamesparks.api.responses.PushRegistrationResponse):void {
var registrationId:String = response.getRegistrationId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSPushRegistrationRequest* request = [[GSPushRegistrationRequest alloc] init];
[request setDeviceOS:deviceOS;
[request setPushId:pushId;
[request setCallback:^ (GSPushRegistrationResponse* response) {
NSString* registrationId = [response getRegistrationId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void PushRegistrationRequest_Response(GS& gsInstance, const PushRegistrationResponse& response) {
gsstl::string registrationId = response.getRegistrationId();
GSData scriptData = response.getScriptData();
}
......
PushRegistrationRequest request(gsInstance);
request.SetDeviceOS(deviceOS)
request.SetPushId(pushId)
request.Send(PushRegistrationRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.PushRegistrationRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.PushRegistrationResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createPushRegistrationRequest()
.setDeviceOS(deviceOS)
.setPushId(pushId)
.send(new GSEventListener<PushRegistrationResponse>() {
@Override
public void onEvent(PushRegistrationResponse response) {
String registrationId = response.getRegistrationId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.PushRegistrationRequest();
request.deviceOS = ...;
request.pushId = ...;
var response = request.Send();
var registrationId = response.registrationId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createPushRegistrationRequest();
request.setDeviceOS(...);
request.setPushId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var registrationId = response.registrationId;
var scriptData = response.scriptData;
});
Registers the current device for push notifications. Currently GameSparks supports iOS, Android (GCM), FCM, Kindle, Viber & Microsoft Push notifications.
Supply the device type, and the push notification identifier for the device.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
deviceOS | Yes | string | The type of id, valid values are ios, android, fcm, wp8, w8, kindle or viber |
pushId | Yes | string | The push notification identifier for the device |
Response Parameters
A response to a push registration request
Parameter | Type | Description |
---|---|---|
registrationId | string | An identifier for the successful registration. Clients should store this value to be used in the event the player no longer wants to receive push notifications to this device. |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
deviceOS | IOS | ANDROID |
SocialStatusRequest
{
"@class" : ".SocialStatusRequest"
}
{
"@class" : ".SocialStatusResponse",
"scriptData" : { },
"statuses" : [ {
"active" : false,
"expires" : "2018-07-11T14:02Z",
"systemId" : ""
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SocialStatusRequest()
.Send((response) => {
GSData scriptData = response.ScriptData;
GSEnumerable<var> statuses = response.Statuses;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSocialStatusRequest()
.send(function(response:com.gamesparks.api.responses.SocialStatusResponse):void {
var scriptData:ScriptData = response.getScriptData();
var statuses:Vector.<SocialStatus> = response.getStatuses();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSocialStatusRequest* request = [[GSSocialStatusRequest alloc] init];
[request setCallback:^ (GSSocialStatusResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSArray* statuses = [response getStatuses];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SocialStatusRequest_Response(GS& gsInstance, const SocialStatusResponse& response) {
GSData scriptData = response.getScriptData();
gsstl:vector<Types::SocialStatus*> statuses = response.getStatuses();
}
......
SocialStatusRequest request(gsInstance);
request.Send(SocialStatusRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SocialStatusRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SocialStatusResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSocialStatusRequest()
.send(new GSEventListener<SocialStatusResponse>() {
@Override
public void onEvent(SocialStatusResponse response) {
GSData scriptData = response.getScriptData();
List<SocialStatus> statuses = response.getStatuses();
}
});
var request = new SparkRequests.SocialStatusRequest();
var response = request.Send();
var scriptData = response.scriptData;
var statuses = response.statuses;
var request = RTSession.newRequest().createSocialStatusRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var statuses = response.statuses;
});
Returns detials of the current social connections of this player. Each connection .
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing the details of a the players social connections
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
statuses | SocialStatus[] | A list of social statuses. |
Multiplayer
AcceptChallengeRequest
{
"@class" : ".AcceptChallengeRequest",
"challengeInstanceId" : "",
"message" : ""
}
{
"@class" : ".AcceptChallengeResponse",
"challengeInstanceId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AcceptChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetMessage(message)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAcceptChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.AcceptChallengeResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAcceptChallengeRequest* request = [[GSAcceptChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setMessage:message;
[request setCallback:^ (GSAcceptChallengeResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AcceptChallengeRequest_Response(GS& gsInstance, const AcceptChallengeResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
......
AcceptChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetMessage(message)
request.Send(AcceptChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AcceptChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AcceptChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAcceptChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(new GSEventListener<AcceptChallengeResponse>() {
@Override
public void onEvent(AcceptChallengeResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.AcceptChallengeRequest();
request.challengeInstanceId = ...;
request.message = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createAcceptChallengeRequest();
request.setChallengeInstanceId(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
});
Accepts a challenge that has been issued to the current player.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response containing the challenge instance id that was accepted.
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The ID of the challenge |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The ID does not match a challenge the user is involved with |
ChatOnChallengeRequest
{
"@class" : ".ChatOnChallengeRequest",
"challengeInstanceId" : "",
"message" : ""
}
{
"@class" : ".ChatOnChallengeResponse",
"challengeInstanceId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ChatOnChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetMessage(message)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createChatOnChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.ChatOnChallengeResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSChatOnChallengeRequest* request = [[GSChatOnChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setMessage:message;
[request setCallback:^ (GSChatOnChallengeResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ChatOnChallengeRequest_Response(GS& gsInstance, const ChatOnChallengeResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
......
ChatOnChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetMessage(message)
request.Send(ChatOnChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ChatOnChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ChatOnChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createChatOnChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(new GSEventListener<ChatOnChallengeResponse>() {
@Override
public void onEvent(ChatOnChallengeResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ChatOnChallengeRequest();
request.challengeInstanceId = ...;
request.message = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createChatOnChallengeRequest();
request.setChallengeInstanceId(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
});
Sends a message to all players involved in the challenge. The current player must be involved in the challenge for the message to be sent.
As the message is sent to all players, the current player will also see details of the message in the response. Read the section on response message aggregation for a description of this.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response to a chat on challenge request
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The challenge instance id |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The ID does not match a challenge the current player is involved with |
CreateChallengeRequest
{
"@class" : ".CreateChallengeRequest",
"accessType" : "",
"autoStartJoinedChallengeOnMaxPlayers" : false,
"challengeMessage" : "",
"challengeShortCode" : "",
"currency1Wager" : 0,
"currency2Wager" : 0,
"currency3Wager" : 0,
"currency4Wager" : 0,
"currency5Wager" : 0,
"currency6Wager" : 0,
"currencyWagers" : { },
"eligibilityCriteria" : { },
"endTime" : "2018-07-11T14:02Z",
"expiryTime" : "2018-07-11T14:02Z",
"maxAttempts" : 0,
"maxPlayers" : 0,
"minPlayers" : 0,
"silent" : false,
"startTime" : "2018-07-11T14:02Z",
"usersToChallenge" : [ "" ]
}
{
"@class" : ".CreateChallengeResponse",
"challengeInstanceId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new CreateChallengeRequest()
.SetAccessType(accessType)
.SetAutoStartJoinedChallengeOnMaxPlayers(autoStartJoinedChallengeOnMaxPlayers)
.SetChallengeMessage(challengeMessage)
.SetChallengeShortCode(challengeShortCode)
.SetCurrency1Wager(currency1Wager)
.SetCurrency2Wager(currency2Wager)
.SetCurrency3Wager(currency3Wager)
.SetCurrency4Wager(currency4Wager)
.SetCurrency5Wager(currency5Wager)
.SetCurrency6Wager(currency6Wager)
.SetCurrencyWagers(currencyWagers)
.SetEligibilityCriteria(eligibilityCriteria)
.SetEndTime(endTime)
.SetExpiryTime(expiryTime)
.SetMaxAttempts(maxAttempts)
.SetMaxPlayers(maxPlayers)
.SetMinPlayers(minPlayers)
.SetSilent(silent)
.SetStartTime(startTime)
.SetUsersToChallenge(usersToChallenge)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createCreateChallengeRequest()
.setAccessType(accessType)
.setAutoStartJoinedChallengeOnMaxPlayers(autoStartJoinedChallengeOnMaxPlayers)
.setChallengeMessage(challengeMessage)
.setChallengeShortCode(challengeShortCode)
.setCurrency1Wager(currency1Wager)
.setCurrency2Wager(currency2Wager)
.setCurrency3Wager(currency3Wager)
.setCurrency4Wager(currency4Wager)
.setCurrency5Wager(currency5Wager)
.setCurrency6Wager(currency6Wager)
.setCurrencyWagers(currencyWagers)
.setEligibilityCriteria(eligibilityCriteria)
.setEndTime(endTime)
.setExpiryTime(expiryTime)
.setMaxAttempts(maxAttempts)
.setMaxPlayers(maxPlayers)
.setMinPlayers(minPlayers)
.setSilent(silent)
.setStartTime(startTime)
.setUsersToChallenge(usersToChallenge)
.send(function(response:com.gamesparks.api.responses.CreateChallengeResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSCreateChallengeRequest* request = [[GSCreateChallengeRequest alloc] init];
[request setAccessType:accessType;
[request setAutoStartJoinedChallengeOnMaxPlayers:autoStartJoinedChallengeOnMaxPlayers;
[request setChallengeMessage:challengeMessage;
[request setChallengeShortCode:challengeShortCode;
[request setCurrency1Wager:currency1Wager;
[request setCurrency2Wager:currency2Wager;
[request setCurrency3Wager:currency3Wager;
[request setCurrency4Wager:currency4Wager;
[request setCurrency5Wager:currency5Wager;
[request setCurrency6Wager:currency6Wager;
[request setCurrencyWagers:currencyWagers;
[request setEligibilityCriteria:eligibilityCriteria;
[request setEndTime:endTime;
[request setExpiryTime:expiryTime;
[request setMaxAttempts:maxAttempts;
[request setMaxPlayers:maxPlayers;
[request setMinPlayers:minPlayers;
[request setSilent:silent;
[request setStartTime:startTime;
[request setUsersToChallenge:usersToChallenge;
[request setCallback:^ (GSCreateChallengeResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void CreateChallengeRequest_Response(GS& gsInstance, const CreateChallengeResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
......
CreateChallengeRequest request(gsInstance);
request.SetAccessType(accessType)
request.SetAutoStartJoinedChallengeOnMaxPlayers(autoStartJoinedChallengeOnMaxPlayers)
request.SetChallengeMessage(challengeMessage)
request.SetChallengeShortCode(challengeShortCode)
request.SetCurrency1Wager(currency1Wager)
request.SetCurrency2Wager(currency2Wager)
request.SetCurrency3Wager(currency3Wager)
request.SetCurrency4Wager(currency4Wager)
request.SetCurrency5Wager(currency5Wager)
request.SetCurrency6Wager(currency6Wager)
request.SetCurrencyWagers(currencyWagers)
request.SetEligibilityCriteria(eligibilityCriteria)
request.SetEndTime(endTime)
request.SetExpiryTime(expiryTime)
request.SetMaxAttempts(maxAttempts)
request.SetMaxPlayers(maxPlayers)
request.SetMinPlayers(minPlayers)
request.SetSilent(silent)
request.SetStartTime(startTime)
request.SetUsersToChallenge(usersToChallenge)
request.Send(CreateChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.CreateChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.CreateChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createCreateChallengeRequest()
.setAccessType(accessType)
.setAutoStartJoinedChallengeOnMaxPlayers(autoStartJoinedChallengeOnMaxPlayers)
.setChallengeMessage(challengeMessage)
.setChallengeShortCode(challengeShortCode)
.setCurrency1Wager(currency1Wager)
.setCurrency2Wager(currency2Wager)
.setCurrency3Wager(currency3Wager)
.setCurrency4Wager(currency4Wager)
.setCurrency5Wager(currency5Wager)
.setCurrency6Wager(currency6Wager)
.setCurrencyWagers(currencyWagers)
.setEligibilityCriteria(eligibilityCriteria)
.setEndTime(endTime)
.setExpiryTime(expiryTime)
.setMaxAttempts(maxAttempts)
.setMaxPlayers(maxPlayers)
.setMinPlayers(minPlayers)
.setSilent(silent)
.setStartTime(startTime)
.setUsersToChallenge(usersToChallenge)
.send(new GSEventListener<CreateChallengeResponse>() {
@Override
public void onEvent(CreateChallengeResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.CreateChallengeRequest();
request.accessType = ...;
request.autoStartJoinedChallengeOnMaxPlayers = ...;
request.challengeMessage = ...;
request.challengeShortCode = ...;
request.currency1Wager = ...;
request.currency2Wager = ...;
request.currency3Wager = ...;
request.currency4Wager = ...;
request.currency5Wager = ...;
request.currency6Wager = ...;
request.currencyWagers = ...;
request.eligibilityCriteria = ...;
request.endTime = ...;
request.expiryTime = ...;
request.maxAttempts = ...;
request.maxPlayers = ...;
request.minPlayers = ...;
request.silent = ...;
request.startTime = ...;
request.usersToChallenge = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createCreateChallengeRequest();
request.setAccessType(...);
request.setAutoStartJoinedChallengeOnMaxPlayers(...);
request.setChallengeMessage(...);
request.setChallengeShortCode(...);
request.setCurrency1Wager(...);
request.setCurrency2Wager(...);
request.setCurrency3Wager(...);
request.setCurrency4Wager(...);
request.setCurrency5Wager(...);
request.setCurrency6Wager(...);
request.setCurrencyWagers(...);
request.setEligibilityCriteria(...);
request.setEndTime(...);
request.setExpiryTime(...);
request.setMaxAttempts(...);
request.setMaxPlayers(...);
request.setMinPlayers(...);
request.setSilent(...);
request.setStartTime(...);
request.setUsersToChallenge(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
});
Issues a challenge to a group of players from the currently signed in player.
The endTime field must be present unless the challenge template has an achievement set in the ‘First to Achievement’ field.
The usersToChallenge field must be present for this request if the acessType is PRIVATE (which is the default).
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessType | No | string | Who can join this challenge. Either PUBLIC, PRIVATE or FRIENDS |
autoStartJoinedChallengeOnMaxPlayers | No | boolean | Whether this challenge should automatically start when a new player joins and maxPlayers is reached |
challengeMessage | No | string | An optional message to include with the challenge |
challengeShortCode | Yes | string | The short code of the challenge |
currency1Wager | No | number | The ammount of currency type 1 that the player is wagering on this challenge |
currency2Wager | No | number | The amount of currency type 2 that the player is wagering on this challenge |
currency3Wager | No | number | The amount of currency type 3 that the player is wagering on this challenge |
currency4Wager | No | number | The amount of currency type 4 that the player is wagering on this challenge |
currency5Wager | No | number | The amount of currency type 5 that the player is wagering on this challenge |
currency6Wager | No | number | The amount of currency type 6 that the player is wagering on this challenge |
currencyWagers | No | JSON | A JSON object containing the amounts of named currencies that the player is wagering on this challenge |
eligibilityCriteria | No | JSON | Criteria for who can and cannot find and join this challenge (when the accessType is PUBLIC or FRIENDS). |
endTime | No | date | The time at which this challenge will end. This is required when the challenge is not linked to an achievement |
expiryTime | No | date | The latest time that players can join this challenge |
maxAttempts | No | number | The maximum number of attempts |
maxPlayers | No | number | The maximum number of players that are allowed to join this challenge |
minPlayers | No | number | The minimum number of players that are allowed to join this challenge |
silent | No | boolean | If True no messaging is triggered |
startTime | No | date | The time at which this challenge will begin |
usersToChallenge | No | string[] | A player id or an array of player ids who will recieve this challenge |
Response Parameters
A response to a create challenge response
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The challenge instance id |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The ID does not match a challenge the user is involved with |
eligibilityCriteria | { “XXX” : “UNRECOGNISED”} | XXX is not a valid field of eligibilityCriteria |
eligibilityCriteria | { “segments” : {“XXX” : “MALFORMED”}} | The value provided for XXX is not in the correct format |
autoStartJoinedChallengeOnMaxPlayers | MaxPlayers Required | If autoStartJoinedChallengeOnMaxPlayers is true, the maximum number of players must also be specified |
DeclineChallengeRequest
{
"@class" : ".DeclineChallengeRequest",
"challengeInstanceId" : "",
"message" : ""
}
{
"@class" : ".DeclineChallengeResponse",
"challengeInstanceId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new DeclineChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetMessage(message)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createDeclineChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.DeclineChallengeResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSDeclineChallengeRequest* request = [[GSDeclineChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setMessage:message;
[request setCallback:^ (GSDeclineChallengeResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void DeclineChallengeRequest_Response(GS& gsInstance, const DeclineChallengeResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
......
DeclineChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetMessage(message)
request.Send(DeclineChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.DeclineChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.DeclineChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createDeclineChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(new GSEventListener<DeclineChallengeResponse>() {
@Override
public void onEvent(DeclineChallengeResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.DeclineChallengeRequest();
request.challengeInstanceId = ...;
request.message = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createDeclineChallengeRequest();
request.setChallengeInstanceId(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
});
Declines a challenge that has been issued to the current player.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response containing the challenge instance id of the challenge that was declined
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | The challenge instance id |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The ID does not match a challenge that has been issued |
FindChallengeRequest
{
"@class" : ".FindChallengeRequest",
"accessType" : "",
"count" : 0,
"eligibility" : { },
"offset" : 0,
"shortCode" : [ "" ]
}
{
"@class" : ".FindChallengeResponse",
"challengeInstances" : [ {
"accepted" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challengeId" : "",
"challengeMessage" : "",
"challengeName" : "",
"challenged" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challenger" : {
"externalIds" : { },
"id" : "",
"name" : ""
},
"currency1Wager" : 0,
"currency2Wager" : 0,
"currency3Wager" : 0,
"currency4Wager" : 0,
"currency5Wager" : 0,
"currency6Wager" : 0,
"currencyWagers" : { },
"declined" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"endDate" : "2018-07-11T14:02Z",
"expiryDate" : "2018-07-11T14:02Z",
"maxTurns" : 0,
"nextPlayer" : "",
"scriptData" : { },
"shortCode" : "",
"startDate" : "2018-07-11T14:02Z",
"state" : "",
"turnCount" : [ {
"count" : "",
"playerId" : ""
} ]
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new FindChallengeRequest()
.SetAccessType(accessType)
.SetCount(count)
.SetEligibility(eligibility)
.SetOffset(offset)
.SetShortCode(shortCode)
.Send((response) => {
GSEnumerable<var> challengeInstances = response.ChallengeInstances;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createFindChallengeRequest()
.setAccessType(accessType)
.setCount(count)
.setEligibility(eligibility)
.setOffset(offset)
.setShortCode(shortCode)
.send(function(response:com.gamesparks.api.responses.FindChallengeResponse):void {
var challengeInstances:Vector.<Challenge> = response.getChallengeInstances();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSFindChallengeRequest* request = [[GSFindChallengeRequest alloc] init];
[request setAccessType:accessType;
[request setCount:count;
[request setEligibility:eligibility;
[request setOffset:offset;
[request setShortCode:shortCode;
[request setCallback:^ (GSFindChallengeResponse* response) {
NSArray* challengeInstances = [response getChallengeInstances];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void FindChallengeRequest_Response(GS& gsInstance, const FindChallengeResponse& response) {
gsstl:vector<Types::Challenge*> challengeInstances = response.getChallengeInstances();
GSData scriptData = response.getScriptData();
}
......
FindChallengeRequest request(gsInstance);
request.SetAccessType(accessType)
request.SetCount(count)
request.SetEligibility(eligibility)
request.SetOffset(offset)
request.SetShortCode(shortCode)
request.Send(FindChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.FindChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.FindChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createFindChallengeRequest()
.setAccessType(accessType)
.setCount(count)
.setEligibility(eligibility)
.setOffset(offset)
.setShortCode(shortCode)
.send(new GSEventListener<FindChallengeResponse>() {
@Override
public void onEvent(FindChallengeResponse response) {
List<Challenge> challengeInstances = response.getChallengeInstances();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.FindChallengeRequest();
request.accessType = ...;
request.count = ...;
request.eligibility = ...;
request.offset = ...;
request.shortCode = ...;
var response = request.Send();
var challengeInstances = response.challengeInstances;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createFindChallengeRequest();
request.setAccessType(...);
request.setCount(...);
request.setEligibility(...);
request.setOffset(...);
request.setShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstances = response.challengeInstances;
var scriptData = response.scriptData;
});
Allows a player to find challenges that they are eligible to join.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
accessType | Yes | string | The type of challenge to find, either PUBLIC or FRIENDS. Defaults to FRIENDS |
count | No | number | The number of challenges to return (MAX=50) |
eligibility | Yes | JSON | Optional. Allows the current player’s eligibility to be overridden by what is provided here. |
offset | No | number | The offset to start from when returning challenges (used for paging) |
shortCode | No | string[] | Optional shortCodes to filter the results by challenge type |
Response Parameters
A response to a find challenge request
Parameter | Type | Description |
---|---|---|
challengeInstances | Challenge[] | A list of JSON objects representing the challenges. |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
eligibility | { “XXX” : “UNRECOGNISED”} | XXX is not a valid field of eligibility |
eligibility | { “segments” : {“XXX” : “MALFORMED”}} | The value provied for XXX is not in the correct format |
FindMatchRequest
{
"@class" : ".FindMatchRequest",
"action" : "",
"matchGroup" : "",
"matchShortCode" : "",
"skill" : 0
}
{
"@class" : ".FindMatchResponse",
"accessToken" : "",
"host" : "",
"matchData" : { },
"matchId" : "",
"opponents" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"peerId" : 0,
"playerId" : "",
"port" : 0,
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new FindMatchRequest()
.SetAction(action)
.SetMatchGroup(matchGroup)
.SetMatchShortCode(matchShortCode)
.SetSkill(skill)
.Send((response) => {
string accessToken = response.AccessToken;
string host = response.Host;
GSData matchData = response.MatchData;
string matchId = response.MatchId;
GSEnumerable<var> opponents = response.Opponents;
int? peerId = response.PeerId;
string playerId = response.PlayerId;
int? port = response.Port;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createFindMatchRequest()
.setAction(action)
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setSkill(skill)
.send(function(response:com.gamesparks.api.responses.FindMatchResponse):void {
var accessToken:String = response.getAccessToken();
var host:String = response.getHost();
var matchData:Object = response.getMatchData();
var matchId:String = response.getMatchId();
var opponents:Vector.<Player> = response.getOpponents();
var peerId:Number = response.getPeerId();
var playerId:String = response.getPlayerId();
var port:Number = response.getPort();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSFindMatchRequest* request = [[GSFindMatchRequest alloc] init];
[request setAction:action;
[request setMatchGroup:matchGroup;
[request setMatchShortCode:matchShortCode;
[request setSkill:skill;
[request setCallback:^ (GSFindMatchResponse* response) {
NSString* accessToken = [response getAccessToken];
NSString* host = [response getHost];
NSDictionary* matchData = [response getMatchData];
NSString* matchId = [response getMatchId];
NSArray* opponents = [response getOpponents];
NSNumber* peerId = [response getPeerId];
NSString* playerId = [response getPlayerId];
NSNumber* port = [response getPort];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void FindMatchRequest_Response(GS& gsInstance, const FindMatchResponse& response) {
gsstl::string accessToken = response.getAccessToken();
gsstl::string host = response.getHost();
GSData matchData = response.getMatchData();
gsstl::string matchId = response.getMatchId();
gsstl:vector<Types::Player*> opponents = response.getOpponents();
Optional::t_LongOptional peerId = response.getPeerId();
gsstl::string playerId = response.getPlayerId();
Optional::t_LongOptional port = response.getPort();
GSData scriptData = response.getScriptData();
}
......
FindMatchRequest request(gsInstance);
request.SetAction(action)
request.SetMatchGroup(matchGroup)
request.SetMatchShortCode(matchShortCode)
request.SetSkill(skill)
request.Send(FindMatchRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.FindMatchRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.FindMatchResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createFindMatchRequest()
.setAction(action)
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setSkill(skill)
.send(new GSEventListener<FindMatchResponse>() {
@Override
public void onEvent(FindMatchResponse response) {
String accessToken = response.getAccessToken();
String host = response.getHost();
GSData matchData = response.getMatchData();
String matchId = response.getMatchId();
List<Player> opponents = response.getOpponents();
Integer peerId = response.getPeerId();
String playerId = response.getPlayerId();
Integer port = response.getPort();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.FindMatchRequest();
request.action = ...;
request.matchGroup = ...;
request.matchShortCode = ...;
request.skill = ...;
var response = request.Send();
var accessToken = response.accessToken;
var host = response.host;
var matchData = response.matchData;
var matchId = response.matchId;
var opponents = response.opponents;
var peerId = response.peerId;
var playerId = response.playerId;
var port = response.port;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createFindMatchRequest();
request.setAction(...);
request.setMatchGroup(...);
request.setMatchShortCode(...);
request.setSkill(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var accessToken = response.accessToken;
var host = response.host;
var matchData = response.matchData;
var matchId = response.matchId;
var opponents = response.opponents;
var peerId = response.peerId;
var playerId = response.playerId;
var port = response.port;
var scriptData = response.scriptData;
});
@Deprecated. Use MatchmakingRequest instead.
Find a match for this player, using the given skill and matchShortCode.
Players looking for a match using the same matchShortCode will be considered for a match, based on the matchConfig.
Each player must match the other for the match to be found.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
action | No | string | The action to take on the already in-flight request for this match. Currently supported actions are: 'cancel’ |
matchGroup | No | string | Optional. Players will be grouped based on the distinct value passed in here, only players in the same group can be matched together |
matchShortCode | Yes | string | The shortCode of the match type this player is registering for |
skill | No | number | The skill of the player looking for a match |
Response Parameters
A response to a find match request
Parameter | Type | Description |
---|---|---|
accessToken | string | The accessToken used to authenticate this player for this match |
host | string | The host to connect to for this match |
matchData | JSON | MatchData is arbitrary data that can be stored in a Match instance by a Cloud Code script. |
matchId | string | The id for this match instance |
opponents | Player[] | The opponents this player has been matched against |
peerId | number | The peerId of this player within the match |
playerId | string | The id of the current player |
port | number | The port to connect to for this match |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
skill | may not be null | skill must be provided |
matchShortCode | may not be null | matchShortCode must be provided |
matchShortCode | NOT_FOUND | No matchConfig was found with the given matchShortCode |
match | NOT_FOUND | No match was found for the current player |
match | HEAD_TO_HEAD_ONLY | To match multiple opponents please use MatchmakingRequest |
match | NO_DROP_IN_DROP_OUT_AVAILABLE | To use the drop-in-drop-out functionality please use MatchmakingRequest |
match | NO_MANUAL_MATCHMAKING | To use the manual matchmaking functionality please use MatchmakingRequest |
FindPendingMatchesRequest
{
"@class" : ".FindPendingMatchesRequest",
"matchGroup" : "",
"matchShortCode" : "",
"maxMatchesToFind" : 0
}
{
"@class" : ".FindPendingMatchesResponse",
"pendingMatches" : [ {
"id" : "",
"matchData" : { },
"matchGroup" : "",
"matchShortCode" : "",
"matchedPlayers" : [ {
"location" : { },
"participantData" : { },
"playerId" : "",
"skill" : { }
} ],
"skill" : { }
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new FindPendingMatchesRequest()
.SetMatchGroup(matchGroup)
.SetMatchShortCode(matchShortCode)
.SetMaxMatchesToFind(maxMatchesToFind)
.Send((response) => {
GSEnumerable<var> pendingMatches = response.PendingMatches;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createFindPendingMatchesRequest()
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setMaxMatchesToFind(maxMatchesToFind)
.send(function(response:com.gamesparks.api.responses.FindPendingMatchesResponse):void {
var pendingMatches:Vector.<PendingMatch> = response.getPendingMatches();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSFindPendingMatchesRequest* request = [[GSFindPendingMatchesRequest alloc] init];
[request setMatchGroup:matchGroup;
[request setMatchShortCode:matchShortCode;
[request setMaxMatchesToFind:maxMatchesToFind;
[request setCallback:^ (GSFindPendingMatchesResponse* response) {
NSArray* pendingMatches = [response getPendingMatches];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void FindPendingMatchesRequest_Response(GS& gsInstance, const FindPendingMatchesResponse& response) {
gsstl:vector<Types::PendingMatch*> pendingMatches = response.getPendingMatches();
GSData scriptData = response.getScriptData();
}
......
FindPendingMatchesRequest request(gsInstance);
request.SetMatchGroup(matchGroup)
request.SetMatchShortCode(matchShortCode)
request.SetMaxMatchesToFind(maxMatchesToFind)
request.Send(FindPendingMatchesRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.FindPendingMatchesRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.FindPendingMatchesResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createFindPendingMatchesRequest()
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setMaxMatchesToFind(maxMatchesToFind)
.send(new GSEventListener<FindPendingMatchesResponse>() {
@Override
public void onEvent(FindPendingMatchesResponse response) {
List<PendingMatch> pendingMatches = response.getPendingMatches();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.FindPendingMatchesRequest();
request.matchGroup = ...;
request.matchShortCode = ...;
request.maxMatchesToFind = ...;
var response = request.Send();
var pendingMatches = response.pendingMatches;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createFindPendingMatchesRequest();
request.setMatchGroup(...);
request.setMatchShortCode(...);
request.setMaxMatchesToFind(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var pendingMatches = response.pendingMatches;
var scriptData = response.scriptData;
});
Find other pending matches that will match this player’s previously submitted MatchmakingRequest.
Used for manual matching of players, where you want control over which pending match should be chosen.
Each player must match the other for the pending match to be found.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
matchGroup | No | string | Optional. The matchGroup of the match this player previously registeredfor |
matchShortCode | Yes | string | The shortCode of the match this player previously registered for |
maxMatchesToFind | No | number | Optional. The maximum number of pending matches to return (default=10) |
Response Parameters
A response to a FindPendingMatchesRequest
Parameter | Type | Description |
---|---|---|
pendingMatches | PendingMatch[] | A list of JSON objects containing pending matches |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
matchShortCode | may not be null | matchShortCode must be provided |
matchShortCode | NOT_FOUND | No matchConfig was found with the given matchShortCode |
match | NOT_IN_PROGRESS | There is no pending match for this player / shortCode / matchGroup currently in progress |
GetChallengeRequest
{
"@class" : ".GetChallengeRequest",
"challengeInstanceId" : "",
"message" : ""
}
{
"@class" : ".GetChallengeResponse",
"challenge" : {
"accepted" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challengeId" : "",
"challengeMessage" : "",
"challengeName" : "",
"challenged" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challenger" : {
"externalIds" : { },
"id" : "",
"name" : ""
},
"currency1Wager" : 0,
"currency2Wager" : 0,
"currency3Wager" : 0,
"currency4Wager" : 0,
"currency5Wager" : 0,
"currency6Wager" : 0,
"currencyWagers" : { },
"declined" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"endDate" : "2018-07-11T14:02Z",
"expiryDate" : "2018-07-11T14:02Z",
"maxTurns" : 0,
"nextPlayer" : "",
"scriptData" : { },
"shortCode" : "",
"startDate" : "2018-07-11T14:02Z",
"state" : "",
"turnCount" : [ {
"count" : "",
"playerId" : ""
} ]
},
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetMessage(message)
.Send((response) => {
var challenge = response.Challenge;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.GetChallengeResponse):void {
var challenge:Challenge = response.getChallenge();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetChallengeRequest* request = [[GSGetChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setMessage:message;
[request setCallback:^ (GSGetChallengeResponse* response) {
GSChallenge* challenge = [response getChallenge];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetChallengeRequest_Response(GS& gsInstance, const GetChallengeResponse& response) {
Types::Challenge* challenge = response.getChallenge();
GSData scriptData = response.getScriptData();
}
......
GetChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetMessage(message)
request.Send(GetChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(new GSEventListener<GetChallengeResponse>() {
@Override
public void onEvent(GetChallengeResponse response) {
Challenge challenge = response.getChallenge();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.GetChallengeRequest();
request.challengeInstanceId = ...;
request.message = ...;
var response = request.Send();
var challenge = response.challenge;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createGetChallengeRequest();
request.setChallengeInstanceId(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challenge = response.challenge;
var scriptData = response.scriptData;
});
Gets the details of a challenge. The current player must be involved in the challenge for the request to succeed.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response containing the details of a challenge
Parameter | Type | Description |
---|---|---|
challenge | Challenge | A JSON object representing the challenge. |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The supplied challengeInstanceId does not match a challenge related to the current player |
JoinChallengeRequest
{
"@class" : ".JoinChallengeRequest",
"challengeInstanceId" : "",
"eligibility" : { },
"message" : ""
}
{
"@class" : ".JoinChallengeResponse",
"joined" : false,
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new JoinChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetEligibility(eligibility)
.SetMessage(message)
.Send((response) => {
bool? joined = response.Joined;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createJoinChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setEligibility(eligibility)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.JoinChallengeResponse):void {
var joined:Boolean = response.getJoined();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSJoinChallengeRequest* request = [[GSJoinChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setEligibility:eligibility;
[request setMessage:message;
[request setCallback:^ (GSJoinChallengeResponse* response) {
BOOL joined = [response getJoined];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void JoinChallengeRequest_Response(GS& gsInstance, const JoinChallengeResponse& response) {
Optional::t_BoolOptional joined = response.getJoined();
GSData scriptData = response.getScriptData();
}
......
JoinChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetEligibility(eligibility)
request.SetMessage(message)
request.Send(JoinChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.JoinChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.JoinChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createJoinChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setEligibility(eligibility)
.setMessage(message)
.send(new GSEventListener<JoinChallengeResponse>() {
@Override
public void onEvent(JoinChallengeResponse response) {
Boolean joined = response.getJoined();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.JoinChallengeRequest();
request.challengeInstanceId = ...;
request.eligibility = ...;
request.message = ...;
var response = request.Send();
var joined = response.joined;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createJoinChallengeRequest();
request.setChallengeInstanceId(...);
request.setEligibility(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var joined = response.joined;
var scriptData = response.scriptData;
});
Allows a player to join an open challenge.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
eligibility | Yes | JSON | Optional. Allows the current player’s eligibility to be overridden by what is provided here. |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response to a player joining a challenge
Parameter | Type | Description |
---|---|---|
joined | boolean | Whether the player successfully joined the challenge |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | UNKNOWN | No challenge could be found with the given challengeInstanceId |
JOIN | NOT_FRIEND | The player is trying to join a FRIENDS challenge that is owned by someone with whom they are not a friend |
JOIN | Must be a PUBLIC | FRIENDS challenge to join |
eligibility | { “XXX” : “UNRECOGNISED”} | XXX is not a valid field of eligibility |
eligibility | { “segments” : {“XXX” : “MALFORMED”}} | The value provied for XXX is not in the correct format |
eligibility | { “missingSegments” : {“XXX” : [“YYY”, “ZZZ”]}} | To join this challenge the player must have segment XXX with value YYY or ZZZ |
eligibility | { “invalidSegments” : { “actual” : {“XXX” : “YYY”}, “required” : {“XXX” : “ZZZ”}} | This player has segment XXX value YYY however this challenge requires a segment XXX value of ZZZ |
JoinPendingMatchRequest
{
"@class" : ".JoinPendingMatchRequest",
"matchGroup" : "",
"matchShortCode" : "",
"pendingMatchId" : ""
}
{
"@class" : ".JoinPendingMatchResponse",
"pendingMatch" : {
"id" : "",
"matchData" : { },
"matchGroup" : "",
"matchShortCode" : "",
"matchedPlayers" : [ {
"location" : { },
"participantData" : { },
"playerId" : "",
"skill" : { }
} ],
"skill" : { }
},
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new JoinPendingMatchRequest()
.SetMatchGroup(matchGroup)
.SetMatchShortCode(matchShortCode)
.SetPendingMatchId(pendingMatchId)
.Send((response) => {
var pendingMatch = response.PendingMatch;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createJoinPendingMatchRequest()
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setPendingMatchId(pendingMatchId)
.send(function(response:com.gamesparks.api.responses.JoinPendingMatchResponse):void {
var pendingMatch:PendingMatch = response.getPendingMatch();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSJoinPendingMatchRequest* request = [[GSJoinPendingMatchRequest alloc] init];
[request setMatchGroup:matchGroup;
[request setMatchShortCode:matchShortCode;
[request setPendingMatchId:pendingMatchId;
[request setCallback:^ (GSJoinPendingMatchResponse* response) {
GSPendingMatch* pendingMatch = [response getPendingMatch];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void JoinPendingMatchRequest_Response(GS& gsInstance, const JoinPendingMatchResponse& response) {
Types::PendingMatch* pendingMatch = response.getPendingMatch();
GSData scriptData = response.getScriptData();
}
......
JoinPendingMatchRequest request(gsInstance);
request.SetMatchGroup(matchGroup)
request.SetMatchShortCode(matchShortCode)
request.SetPendingMatchId(pendingMatchId)
request.Send(JoinPendingMatchRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.JoinPendingMatchRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.JoinPendingMatchResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createJoinPendingMatchRequest()
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setPendingMatchId(pendingMatchId)
.send(new GSEventListener<JoinPendingMatchResponse>() {
@Override
public void onEvent(JoinPendingMatchResponse response) {
PendingMatch pendingMatch = response.getPendingMatch();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.JoinPendingMatchRequest();
request.matchGroup = ...;
request.matchShortCode = ...;
request.pendingMatchId = ...;
var response = request.Send();
var pendingMatch = response.pendingMatch;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createJoinPendingMatchRequest();
request.setMatchGroup(...);
request.setMatchShortCode(...);
request.setPendingMatchId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var pendingMatch = response.pendingMatch;
var scriptData = response.scriptData;
});
Requests to join a pending match (found via FindPendingMatchesRequest).
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
matchGroup | No | string | Optional. The matchGroup of the match this player previously registeredfor |
matchShortCode | Yes | string | The shortCode of the match this player previously registered for |
pendingMatchId | Yes | string | The pending match ID to join |
Response Parameters
A response to a JoinPendingMatchRequest
Parameter | Type | Description |
---|---|---|
pendingMatch | PendingMatch | A JSON object containing the new pending match |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
matchShortCode | may not be null | matchShortCode must be provided |
matchShortCode | NOT_FOUND | No matchConfig was found with the given matchShortCode |
match | NOT_IN_PROGRESS | There is no pending match for this player / shortCode / matchGroup currently in progress |
pendingMatchId | NOT_AVAILABLE | The requested pending match ID is not available to be joined |
ListChallengeRequest
{
"@class" : ".ListChallengeRequest",
"entryCount" : 0,
"offset" : 0,
"shortCode" : "",
"state" : "",
"states" : [ "" ]
}
{
"@class" : ".ListChallengeResponse",
"challengeInstances" : [ {
"accepted" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challengeId" : "",
"challengeMessage" : "",
"challengeName" : "",
"challenged" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"challenger" : {
"externalIds" : { },
"id" : "",
"name" : ""
},
"currency1Wager" : 0,
"currency2Wager" : 0,
"currency3Wager" : 0,
"currency4Wager" : 0,
"currency5Wager" : 0,
"currency6Wager" : 0,
"currencyWagers" : { },
"declined" : [ {
"externalIds" : { },
"id" : "",
"name" : ""
} ],
"endDate" : "2018-07-11T14:02Z",
"expiryDate" : "2018-07-11T14:02Z",
"maxTurns" : 0,
"nextPlayer" : "",
"scriptData" : { },
"shortCode" : "",
"startDate" : "2018-07-11T14:02Z",
"state" : "",
"turnCount" : [ {
"count" : "",
"playerId" : ""
} ]
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListChallengeRequest()
.SetEntryCount(entryCount)
.SetOffset(offset)
.SetShortCode(shortCode)
.SetState(state)
.SetStates(states)
.Send((response) => {
GSEnumerable<var> challengeInstances = response.ChallengeInstances;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListChallengeRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setShortCode(shortCode)
.setState(state)
.setStates(states)
.send(function(response:com.gamesparks.api.responses.ListChallengeResponse):void {
var challengeInstances:Vector.<Challenge> = response.getChallengeInstances();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListChallengeRequest* request = [[GSListChallengeRequest alloc] init];
[request setEntryCount:entryCount;
[request setOffset:offset;
[request setShortCode:shortCode;
[request setState:state;
[request setStates:states;
[request setCallback:^ (GSListChallengeResponse* response) {
NSArray* challengeInstances = [response getChallengeInstances];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListChallengeRequest_Response(GS& gsInstance, const ListChallengeResponse& response) {
gsstl:vector<Types::Challenge*> challengeInstances = response.getChallengeInstances();
GSData scriptData = response.getScriptData();
}
......
ListChallengeRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetOffset(offset)
request.SetShortCode(shortCode)
request.SetState(state)
request.SetStates(states)
request.Send(ListChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListChallengeRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setShortCode(shortCode)
.setState(state)
.setStates(states)
.send(new GSEventListener<ListChallengeResponse>() {
@Override
public void onEvent(ListChallengeResponse response) {
List<Challenge> challengeInstances = response.getChallengeInstances();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListChallengeRequest();
request.entryCount = ...;
request.offset = ...;
request.shortCode = ...;
request.state = ...;
request.states = ...;
var response = request.Send();
var challengeInstances = response.challengeInstances;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListChallengeRequest();
request.setEntryCount(...);
request.setOffset(...);
request.setShortCode(...);
request.setState(...);
request.setStates(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstances = response.challengeInstances;
var scriptData = response.scriptData;
});
Returns a list of challenges in the state defined in the 'state’ field.
The response can be further filtered by passing a shortCode field which will limit the returned lists to challenges of that short code.
Valid states are:
WAITING : The challenge has been issued and accepted and is waiting for the start date.
RUNNING : The challenge is active.
ISSUED : The challenge has been issued by the current player and is waiting to be accepted.
RECEIVED : The challenge has been issued to the current player and is waiting to be accepted.
COMPLETE : The challenge has completed.
DECLINED : The challenge has been issued by the current player and has been declined.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of items to return in a page (default=50) |
offset | No | number | The offset (page number) to start from (default=0) |
shortCode | No | string | The type of challenge to return |
state | No | string | The state of the challenged to be returned |
states | No | string[] | The states of the challenges to be returned |
Response Parameters
A response containing challenges that are in the state that was specified in the request
Parameter | Type | Description |
---|---|---|
challengeInstances | Challenge[] | A list of JSON objects representing the challenges. |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListChallengeTypeRequest
{
"@class" : ".ListChallengeTypeRequest"
}
{
"@class" : ".ListChallengeTypeResponse",
"challengeTemplates" : [ {
"challengeShortCode" : "",
"description" : "",
"getleaderboardName" : "",
"name" : "",
"tags" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListChallengeTypeRequest()
.Send((response) => {
GSEnumerable<var> challengeTemplates = response.ChallengeTemplates;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListChallengeTypeRequest()
.send(function(response:com.gamesparks.api.responses.ListChallengeTypeResponse):void {
var challengeTemplates:Vector.<ChallengeType> = response.getChallengeTemplates();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListChallengeTypeRequest* request = [[GSListChallengeTypeRequest alloc] init];
[request setCallback:^ (GSListChallengeTypeResponse* response) {
NSArray* challengeTemplates = [response getChallengeTemplates];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListChallengeTypeRequest_Response(GS& gsInstance, const ListChallengeTypeResponse& response) {
gsstl:vector<Types::ChallengeType*> challengeTemplates = response.getChallengeTemplates();
GSData scriptData = response.getScriptData();
}
......
ListChallengeTypeRequest request(gsInstance);
request.Send(ListChallengeTypeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListChallengeTypeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListChallengeTypeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListChallengeTypeRequest()
.send(new GSEventListener<ListChallengeTypeResponse>() {
@Override
public void onEvent(ListChallengeTypeResponse response) {
List<ChallengeType> challengeTemplates = response.getChallengeTemplates();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListChallengeTypeRequest();
var response = request.Send();
var challengeTemplates = response.challengeTemplates;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListChallengeTypeRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeTemplates = response.challengeTemplates;
var scriptData = response.scriptData;
});
Returns the list of configured challenge types.
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing the list of configured challenge types in the game
Parameter | Type | Description |
---|---|---|
challengeTemplates | ChallengeType[] | A list of JSON objects containing the challenge templates for the game |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
LogChallengeEventRequest
{
"@class" : ".LogChallengeEventRequest",
"challengeInstanceId" : "",
"eventKey" : ""
}
{
"@class" : ".LogChallengeEventResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new LogChallengeEventRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetEventKey(eventKey)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createLogChallengeEventRequest()
.setChallengeInstanceId(challengeInstanceId)
.setEventKey(eventKey)
.send(function(response:com.gamesparks.api.responses.LogChallengeEventResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSLogChallengeEventRequest* request = [[GSLogChallengeEventRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setEventKey:eventKey;
[request setCallback:^ (GSLogChallengeEventResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void LogChallengeEventRequest_Response(GS& gsInstance, const LogChallengeEventResponse& response) {
GSData scriptData = response.getScriptData();
}
......
LogChallengeEventRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetEventKey(eventKey)
request.Send(LogChallengeEventRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LogChallengeEventRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LogChallengeEventResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createLogChallengeEventRequest()
.setChallengeInstanceId(challengeInstanceId)
.setEventKey(eventKey)
.send(new GSEventListener<LogChallengeEventResponse>() {
@Override
public void onEvent(LogChallengeEventResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.LogChallengeEventRequest();
request.challengeInstanceId = ...;
request.eventKey = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createLogChallengeEventRequest();
request.setChallengeInstanceId(...);
request.setEventKey(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a user defined event to be triggered. The event will be posted to the challenge specified.
This call differs from most as it does not have a fixed format. The @class, challengeInstanceId and eventKey attributes are common, but the rest of the attributes are as defined in the Event object configured in the dev portal.
The example below shows a request to en event with a short code of HS with 2 attributes, 'HS’ & 'GL’.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID challenge instance to target |
eventKey | Yes | string | The short code of the event to trigger |
Response Parameters
A response to a log challenge event request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The challengeInstanceId does not match a challenge the user has access to |
[attribute short code] | REQUIRED | Each attribute defined in the event must be supplied. |
MatchDetailsRequest
{
"@class" : ".MatchDetailsRequest",
"matchId" : "",
"realtimeEnabled" : false
}
{
"@class" : ".MatchDetailsResponse",
"accessToken" : "",
"host" : "",
"matchData" : { },
"matchId" : "",
"opponents" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"peerId" : 0,
"playerId" : "",
"port" : 0,
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new MatchDetailsRequest()
.SetMatchId(matchId)
.SetRealtimeEnabled(realtimeEnabled)
.Send((response) => {
string accessToken = response.AccessToken;
string host = response.Host;
GSData matchData = response.MatchData;
string matchId = response.MatchId;
GSEnumerable<var> opponents = response.Opponents;
int? peerId = response.PeerId;
string playerId = response.PlayerId;
int? port = response.Port;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createMatchDetailsRequest()
.setMatchId(matchId)
.setRealtimeEnabled(realtimeEnabled)
.send(function(response:com.gamesparks.api.responses.MatchDetailsResponse):void {
var accessToken:String = response.getAccessToken();
var host:String = response.getHost();
var matchData:Object = response.getMatchData();
var matchId:String = response.getMatchId();
var opponents:Vector.<Player> = response.getOpponents();
var peerId:Number = response.getPeerId();
var playerId:String = response.getPlayerId();
var port:Number = response.getPort();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSMatchDetailsRequest* request = [[GSMatchDetailsRequest alloc] init];
[request setMatchId:matchId;
[request setRealtimeEnabled:realtimeEnabled;
[request setCallback:^ (GSMatchDetailsResponse* response) {
NSString* accessToken = [response getAccessToken];
NSString* host = [response getHost];
NSDictionary* matchData = [response getMatchData];
NSString* matchId = [response getMatchId];
NSArray* opponents = [response getOpponents];
NSNumber* peerId = [response getPeerId];
NSString* playerId = [response getPlayerId];
NSNumber* port = [response getPort];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void MatchDetailsRequest_Response(GS& gsInstance, const MatchDetailsResponse& response) {
gsstl::string accessToken = response.getAccessToken();
gsstl::string host = response.getHost();
GSData matchData = response.getMatchData();
gsstl::string matchId = response.getMatchId();
gsstl:vector<Types::Player*> opponents = response.getOpponents();
Optional::t_LongOptional peerId = response.getPeerId();
gsstl::string playerId = response.getPlayerId();
Optional::t_LongOptional port = response.getPort();
GSData scriptData = response.getScriptData();
}
......
MatchDetailsRequest request(gsInstance);
request.SetMatchId(matchId)
request.SetRealtimeEnabled(realtimeEnabled)
request.Send(MatchDetailsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.MatchDetailsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.MatchDetailsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createMatchDetailsRequest()
.setMatchId(matchId)
.setRealtimeEnabled(realtimeEnabled)
.send(new GSEventListener<MatchDetailsResponse>() {
@Override
public void onEvent(MatchDetailsResponse response) {
String accessToken = response.getAccessToken();
String host = response.getHost();
GSData matchData = response.getMatchData();
String matchId = response.getMatchId();
List<Player> opponents = response.getOpponents();
Integer peerId = response.getPeerId();
String playerId = response.getPlayerId();
Integer port = response.getPort();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.MatchDetailsRequest();
request.matchId = ...;
request.realtimeEnabled = ...;
var response = request.Send();
var accessToken = response.accessToken;
var host = response.host;
var matchData = response.matchData;
var matchId = response.matchId;
var opponents = response.opponents;
var peerId = response.peerId;
var playerId = response.playerId;
var port = response.port;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createMatchDetailsRequest();
request.setMatchId(...);
request.setRealtimeEnabled(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var accessToken = response.accessToken;
var host = response.host;
var matchData = response.matchData;
var matchId = response.matchId;
var opponents = response.opponents;
var peerId = response.peerId;
var playerId = response.playerId;
var port = response.port;
var scriptData = response.scriptData;
});
Find the details of an existing match this player belongs to, using the matchId
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
matchId | Yes | string | The matchId to find the details of |
realtimeEnabled | No | boolean | Adds realtime server details if the match has been created using Cloud Code and it has not been realtime enabled |
Response Parameters
A response to a match details request
Parameter | Type | Description |
---|---|---|
accessToken | string | The accessToken used to authenticate this player for this match |
host | string | The host to connect to for this match |
matchData | JSON | MatchData is arbitrary data that can be stored in a Match instance by a Cloud Code script. |
matchId | string | The id for this match instance |
opponents | Player[] | The opponents this player has been matched against |
peerId | number | The peerId of this player within the match |
playerId | string | The id of the current player |
port | number | The port to connect to for this match |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
matchId | NOT_FOUND | No match found with given matchId for this player |
MatchmakingRequest
{
"@class" : ".MatchmakingRequest",
"action" : "",
"customQuery" : { },
"matchData" : { },
"matchGroup" : "",
"matchShortCode" : "",
"participantData" : { },
"skill" : 0
}
{
"@class" : ".MatchmakingResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new MatchmakingRequest()
.SetAction(action)
.SetCustomQuery(customQuery)
.SetMatchData(matchData)
.SetMatchGroup(matchGroup)
.SetMatchShortCode(matchShortCode)
.SetParticipantData(participantData)
.SetSkill(skill)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createMatchmakingRequest()
.setAction(action)
.setCustomQuery(customQuery)
.setMatchData(matchData)
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setParticipantData(participantData)
.setSkill(skill)
.send(function(response:com.gamesparks.api.responses.MatchmakingResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSMatchmakingRequest* request = [[GSMatchmakingRequest alloc] init];
[request setAction:action;
[request setCustomQuery:customQuery;
[request setMatchData:matchData;
[request setMatchGroup:matchGroup;
[request setMatchShortCode:matchShortCode;
[request setParticipantData:participantData;
[request setSkill:skill;
[request setCallback:^ (GSMatchmakingResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void MatchmakingRequest_Response(GS& gsInstance, const MatchmakingResponse& response) {
GSData scriptData = response.getScriptData();
}
......
MatchmakingRequest request(gsInstance);
request.SetAction(action)
request.SetCustomQuery(customQuery)
request.SetMatchData(matchData)
request.SetMatchGroup(matchGroup)
request.SetMatchShortCode(matchShortCode)
request.SetParticipantData(participantData)
request.SetSkill(skill)
request.Send(MatchmakingRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.MatchmakingRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.MatchmakingResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createMatchmakingRequest()
.setAction(action)
.setCustomQuery(customQuery)
.setMatchData(matchData)
.setMatchGroup(matchGroup)
.setMatchShortCode(matchShortCode)
.setParticipantData(participantData)
.setSkill(skill)
.send(new GSEventListener<MatchmakingResponse>() {
@Override
public void onEvent(MatchmakingResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.MatchmakingRequest();
request.action = ...;
request.customQuery = ...;
request.matchData = ...;
request.matchGroup = ...;
request.matchShortCode = ...;
request.participantData = ...;
request.skill = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createMatchmakingRequest();
request.setAction(...);
request.setCustomQuery(...);
request.setMatchData(...);
request.setMatchGroup(...);
request.setMatchShortCode(...);
request.setParticipantData(...);
request.setSkill(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Register this player for matchmaking, using the given skill and matchShortCode.
Players looking for a match using the same matchShortCode will be considered for a match, based on the matchConfig.
Each player must match the other for the match to be found.
If the matchShortCode points to a match with realtime enabled, in order to minimise latency, the location of Players and their proximity to one another takes precedence over their reciprocal skill values.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
action | No | string | The action to take on the already in-flight request for this match. Currently supported actions are: 'cancel’ |
customQuery | No | JSON | The query that will be applied to the PendingMatch collection |
matchData | No | JSON | A JSON Map of any data that will be associated to the pending match |
matchGroup | No | string | Optional. Players will be grouped based on the distinct value passed in here, only players in the same group can be matched together |
matchShortCode | Yes | string | The shortCode of the match type this player is registering for |
participantData | No | JSON | A JSON Map of any data that will be associated to this user in a pending match |
skill | No | number | The skill of the player looking for a match |
Response Parameters
A response to a matchmaking request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
skill | may not be null | skill must be provided |
action | UNKNOWN | action is not valid |
matchShortCode | may not be null | matchShortCode must be provided |
matchShortCode | NOT_FOUND | No matchConfig was found with the given matchShortCode |
customQuery | INVALID_QUERY | No customQuery is not a valid mongo query |
match | NOT_FOUND | No match was found for the current player |
WithdrawChallengeRequest
{
"@class" : ".WithdrawChallengeRequest",
"challengeInstanceId" : "",
"message" : ""
}
{
"@class" : ".WithdrawChallengeResponse",
"challengeInstanceId" : "",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new WithdrawChallengeRequest()
.SetChallengeInstanceId(challengeInstanceId)
.SetMessage(message)
.Send((response) => {
string challengeInstanceId = response.ChallengeInstanceId;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createWithdrawChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.WithdrawChallengeResponse):void {
var challengeInstanceId:String = response.getChallengeInstanceId();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSWithdrawChallengeRequest* request = [[GSWithdrawChallengeRequest alloc] init];
[request setChallengeInstanceId:challengeInstanceId;
[request setMessage:message;
[request setCallback:^ (GSWithdrawChallengeResponse* response) {
NSString* challengeInstanceId = [response getChallengeInstanceId];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void WithdrawChallengeRequest_Response(GS& gsInstance, const WithdrawChallengeResponse& response) {
gsstl::string challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
......
WithdrawChallengeRequest request(gsInstance);
request.SetChallengeInstanceId(challengeInstanceId)
request.SetMessage(message)
request.Send(WithdrawChallengeRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.WithdrawChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.WithdrawChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createWithdrawChallengeRequest()
.setChallengeInstanceId(challengeInstanceId)
.setMessage(message)
.send(new GSEventListener<WithdrawChallengeResponse>() {
@Override
public void onEvent(WithdrawChallengeResponse response) {
String challengeInstanceId = response.getChallengeInstanceId();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.WithdrawChallengeRequest();
request.challengeInstanceId = ...;
request.message = ...;
var response = request.Send();
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createWithdrawChallengeRequest();
request.setChallengeInstanceId(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var challengeInstanceId = response.challengeInstanceId;
var scriptData = response.scriptData;
});
Withdraws a challenge previously issued by the current player.
This can only be done while the challenge is in the ISSUED state. Once it’s been accepted the challenge can not be withdrawn.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
challengeInstanceId | Yes | string | The ID of the challenge |
message | No | string | An optional message to send with the challenge |
Response Parameters
A response containing the challenge instance id that was withdrawn by a player
Parameter | Type | Description |
---|---|---|
challengeInstanceId | string | A challenge instance id |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
challengeInstanceId | INVALID | The ID does not match a challenge in the ISSUED state that was issued by the current player |
Player Operations
AccountDetailsRequest
{
"@class" : ".AccountDetailsRequest"
}
{
"@class" : ".AccountDetailsResponse",
"achievements" : [ "" ],
"currencies" : { },
"currency1" : 0,
"currency2" : 0,
"currency3" : 0,
"currency4" : 0,
"currency5" : 0,
"currency6" : 0,
"displayName" : "",
"externalIds" : { },
"location" : {
"city" : "",
"country" : "",
"latitide" : { },
"longditute" : { }
},
"reservedCurrencies" : { },
"reservedCurrency1" : { },
"reservedCurrency2" : { },
"reservedCurrency3" : { },
"reservedCurrency4" : { },
"reservedCurrency5" : { },
"reservedCurrency6" : { },
"userId" : "",
"virtualGoods" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AccountDetailsRequest()
.Send((response) => {
IList<string> achievements = response.Achievements;
GSData currencies = response.Currencies;
long? currency1 = response.Currency1;
long? currency2 = response.Currency2;
long? currency3 = response.Currency3;
long? currency4 = response.Currency4;
long? currency5 = response.Currency5;
long? currency6 = response.Currency6;
string displayName = response.DisplayName;
GSData externalIds = response.ExternalIds;
var location = response.Location;
GSData reservedCurrencies = response.ReservedCurrencies;
GSData reservedCurrency1 = response.ReservedCurrency1;
GSData reservedCurrency2 = response.ReservedCurrency2;
GSData reservedCurrency3 = response.ReservedCurrency3;
GSData reservedCurrency4 = response.ReservedCurrency4;
GSData reservedCurrency5 = response.ReservedCurrency5;
GSData reservedCurrency6 = response.ReservedCurrency6;
string userId = response.UserId;
GSData virtualGoods = response.VirtualGoods;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAccountDetailsRequest()
.send(function(response:com.gamesparks.api.responses.AccountDetailsResponse):void {
var achievements:Vector.<String> = response.getAchievements();
var currencies:Object = response.getCurrencies();
var currency1:Number = response.getCurrency1();
var currency2:Number = response.getCurrency2();
var currency3:Number = response.getCurrency3();
var currency4:Number = response.getCurrency4();
var currency5:Number = response.getCurrency5();
var currency6:Number = response.getCurrency6();
var displayName:String = response.getDisplayName();
var externalIds:Object = response.getExternalIds();
var location:Location = response.getLocation();
var reservedCurrencies:Object = response.getReservedCurrencies();
var reservedCurrency1:Object = response.getReservedCurrency1();
var reservedCurrency2:Object = response.getReservedCurrency2();
var reservedCurrency3:Object = response.getReservedCurrency3();
var reservedCurrency4:Object = response.getReservedCurrency4();
var reservedCurrency5:Object = response.getReservedCurrency5();
var reservedCurrency6:Object = response.getReservedCurrency6();
var userId:String = response.getUserId();
var virtualGoods:Object = response.getVirtualGoods();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAccountDetailsRequest* request = [[GSAccountDetailsRequest alloc] init];
[request setCallback:^ (GSAccountDetailsResponse* response) {
NSArray* achievements = [response getAchievements];
NSDictionary* currencies = [response getCurrencies];
NSNumber* currency1 = [response getCurrency1];
NSNumber* currency2 = [response getCurrency2];
NSNumber* currency3 = [response getCurrency3];
NSNumber* currency4 = [response getCurrency4];
NSNumber* currency5 = [response getCurrency5];
NSNumber* currency6 = [response getCurrency6];
NSString* displayName = [response getDisplayName];
NSDictionary* externalIds = [response getExternalIds];
GSLocation* location = [response getLocation];
NSDictionary* reservedCurrencies = [response getReservedCurrencies];
NSDictionary* reservedCurrency1 = [response getReservedCurrency1];
NSDictionary* reservedCurrency2 = [response getReservedCurrency2];
NSDictionary* reservedCurrency3 = [response getReservedCurrency3];
NSDictionary* reservedCurrency4 = [response getReservedCurrency4];
NSDictionary* reservedCurrency5 = [response getReservedCurrency5];
NSDictionary* reservedCurrency6 = [response getReservedCurrency6];
NSString* userId = [response getUserId];
NSDictionary* virtualGoods = [response getVirtualGoods];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AccountDetailsRequest_Response(GS& gsInstance, const AccountDetailsResponse& response) {
gsstl:vector<gsstl::string> achievements = response.getAchievements();
GSData currencies = response.getCurrencies();
Optional::t_LongOptional currency1 = response.getCurrency1();
Optional::t_LongOptional currency2 = response.getCurrency2();
Optional::t_LongOptional currency3 = response.getCurrency3();
Optional::t_LongOptional currency4 = response.getCurrency4();
Optional::t_LongOptional currency5 = response.getCurrency5();
Optional::t_LongOptional currency6 = response.getCurrency6();
gsstl::string displayName = response.getDisplayName();
GSData externalIds = response.getExternalIds();
Types::Location* location = response.getLocation();
GSData reservedCurrencies = response.getReservedCurrencies();
GSData reservedCurrency1 = response.getReservedCurrency1();
GSData reservedCurrency2 = response.getReservedCurrency2();
GSData reservedCurrency3 = response.getReservedCurrency3();
GSData reservedCurrency4 = response.getReservedCurrency4();
GSData reservedCurrency5 = response.getReservedCurrency5();
GSData reservedCurrency6 = response.getReservedCurrency6();
gsstl::string userId = response.getUserId();
GSData virtualGoods = response.getVirtualGoods();
}
......
AccountDetailsRequest request(gsInstance);
request.Send(AccountDetailsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AccountDetailsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AccountDetailsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAccountDetailsRequest()
.send(new GSEventListener<AccountDetailsResponse>() {
@Override
public void onEvent(AccountDetailsResponse response) {
List<String> achievements = response.getAchievements();
GSData currencies = response.getCurrencies();
Long currency1 = response.getCurrency1();
Long currency2 = response.getCurrency2();
Long currency3 = response.getCurrency3();
Long currency4 = response.getCurrency4();
Long currency5 = response.getCurrency5();
Long currency6 = response.getCurrency6();
String displayName = response.getDisplayName();
GSData externalIds = response.getExternalIds();
Location location = response.getLocation();
GSData reservedCurrencies = response.getReservedCurrencies();
GSData reservedCurrency1 = response.getReservedCurrency1();
GSData reservedCurrency2 = response.getReservedCurrency2();
GSData reservedCurrency3 = response.getReservedCurrency3();
GSData reservedCurrency4 = response.getReservedCurrency4();
GSData reservedCurrency5 = response.getReservedCurrency5();
GSData reservedCurrency6 = response.getReservedCurrency6();
String userId = response.getUserId();
GSData virtualGoods = response.getVirtualGoods();
}
});
var request = new SparkRequests.AccountDetailsRequest();
var response = request.Send();
var achievements = response.achievements;
var currencies = response.currencies;
var currency1 = response.currency1;
var currency2 = response.currency2;
var currency3 = response.currency3;
var currency4 = response.currency4;
var currency5 = response.currency5;
var currency6 = response.currency6;
var displayName = response.displayName;
var externalIds = response.externalIds;
var location = response.location;
var reservedCurrencies = response.reservedCurrencies;
var reservedCurrency1 = response.reservedCurrency1;
var reservedCurrency2 = response.reservedCurrency2;
var reservedCurrency3 = response.reservedCurrency3;
var reservedCurrency4 = response.reservedCurrency4;
var reservedCurrency5 = response.reservedCurrency5;
var reservedCurrency6 = response.reservedCurrency6;
var userId = response.userId;
var virtualGoods = response.virtualGoods;
var request = RTSession.newRequest().createAccountDetailsRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var achievements = response.achievements;
var currencies = response.currencies;
var currency1 = response.currency1;
var currency2 = response.currency2;
var currency3 = response.currency3;
var currency4 = response.currency4;
var currency5 = response.currency5;
var currency6 = response.currency6;
var displayName = response.displayName;
var externalIds = response.externalIds;
var location = response.location;
var reservedCurrencies = response.reservedCurrencies;
var reservedCurrency1 = response.reservedCurrency1;
var reservedCurrency2 = response.reservedCurrency2;
var reservedCurrency3 = response.reservedCurrency3;
var reservedCurrency4 = response.reservedCurrency4;
var reservedCurrency5 = response.reservedCurrency5;
var reservedCurrency6 = response.reservedCurrency6;
var userId = response.userId;
var virtualGoods = response.virtualGoods;
});
Retrieves the details of the current authenticated player.
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing the player’s data.
Parameter | Type | Description |
---|---|---|
achievements | string[] | A JSON object containing the player’s achievments |
currencies | JSON | A JSON object containing the player’s currency balances |
currency1 | number | The amount of type 1 currency that the player holds |
currency2 | number | The amount of type 2 currency that the player holds |
currency3 | number | The amount of type 3 currency that the player holds |
currency4 | number | The amount of type 4 currency that the player holds |
currency5 | number | The amount of type 5 currency that the player holds |
currency6 | number | The amount of type 6 currency that the player holds |
displayName | string | The player’s display name |
externalIds | JSON | A JSON object containing the player’s external account details |
location | Location | A JSON object containing the player’s location |
reservedCurrencies | JSON | A JSON object containing the player’s currency balances |
reservedCurrency1 | JSON | The amount of type 1 currency that the player holds which is currently reserved |
reservedCurrency2 | JSON | The amount of type 2 currency that the player holds which is currently reserved |
reservedCurrency3 | JSON | The amount of type 3 currency that the player holds which is currently reserved |
reservedCurrency4 | JSON | The amount of type 4 currency that the player holds which is currently reserved |
reservedCurrency5 | JSON | The amount of type 5 currency that the player holds which is currently reserved |
reservedCurrency6 | JSON | The amount of type 6 currency that the player holds which is currently reserved |
userId | string | The player’s id |
virtualGoods | JSON | A JSON object containing the virtual goods that the player owns |
ChangeUserDetailsRequest
{
"@class" : ".ChangeUserDetailsRequest",
"displayName" : "",
"language" : "",
"newPassword" : "",
"oldPassword" : "",
"userName" : ""
}
{
"@class" : ".ChangeUserDetailsResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ChangeUserDetailsRequest()
.SetDisplayName(displayName)
.SetLanguage(language)
.SetNewPassword(newPassword)
.SetOldPassword(oldPassword)
.SetUserName(userName)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createChangeUserDetailsRequest()
.setDisplayName(displayName)
.setLanguage(language)
.setNewPassword(newPassword)
.setOldPassword(oldPassword)
.setUserName(userName)
.send(function(response:com.gamesparks.api.responses.ChangeUserDetailsResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSChangeUserDetailsRequest* request = [[GSChangeUserDetailsRequest alloc] init];
[request setDisplayName:displayName;
[request setLanguage:language;
[request setNewPassword:newPassword;
[request setOldPassword:oldPassword;
[request setUserName:userName;
[request setCallback:^ (GSChangeUserDetailsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ChangeUserDetailsRequest_Response(GS& gsInstance, const ChangeUserDetailsResponse& response) {
GSData scriptData = response.getScriptData();
}
......
ChangeUserDetailsRequest request(gsInstance);
request.SetDisplayName(displayName)
request.SetLanguage(language)
request.SetNewPassword(newPassword)
request.SetOldPassword(oldPassword)
request.SetUserName(userName)
request.Send(ChangeUserDetailsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ChangeUserDetailsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ChangeUserDetailsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createChangeUserDetailsRequest()
.setDisplayName(displayName)
.setLanguage(language)
.setNewPassword(newPassword)
.setOldPassword(oldPassword)
.setUserName(userName)
.send(new GSEventListener<ChangeUserDetailsResponse>() {
@Override
public void onEvent(ChangeUserDetailsResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ChangeUserDetailsRequest();
request.displayName = ...;
request.language = ...;
request.newPassword = ...;
request.oldPassword = ...;
request.userName = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createChangeUserDetailsRequest();
request.setDisplayName(...);
request.setLanguage(...);
request.setNewPassword(...);
request.setOldPassword(...);
request.setUserName(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Change the details of the currently signed in Player.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
displayName | No | string | The new display name to set in the player data. |
language | No | string | The new language code to set in the player data. |
newPassword | No | string | The new password to set in the player data. |
oldPassword | No | string | The player’s existing password. If supplied it will be checked against the password stored in the player data. This allows you re-authenticate the player making the change. |
userName | No | string | The new userName with which this player will sign in. If the player currently authenticates using device authentication this will upgrade their account and require them to use username and password authentication from now on. |
Response Parameters
A response to a change user details request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
DETAILS | UNRECOGNISED | The oldPassword did not match the one stored against the player. |
USERNAME | TAKEN | The userName supplied is already in use. |
DismissMessageRequest
{
"@class" : ".DismissMessageRequest",
"messageId" : ""
}
{
"@class" : ".DismissMessageResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new DismissMessageRequest()
.SetMessageId(messageId)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createDismissMessageRequest()
.setMessageId(messageId)
.send(function(response:com.gamesparks.api.responses.DismissMessageResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSDismissMessageRequest* request = [[GSDismissMessageRequest alloc] init];
[request setMessageId:messageId;
[request setCallback:^ (GSDismissMessageResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void DismissMessageRequest_Response(GS& gsInstance, const DismissMessageResponse& response) {
GSData scriptData = response.getScriptData();
}
......
DismissMessageRequest request(gsInstance);
request.SetMessageId(messageId)
request.Send(DismissMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.DismissMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.DismissMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createDismissMessageRequest()
.setMessageId(messageId)
.send(new GSEventListener<DismissMessageResponse>() {
@Override
public void onEvent(DismissMessageResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.DismissMessageRequest();
request.messageId = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createDismissMessageRequest();
request.setMessageId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a message to be dismissed. Once dismissed the message will no longer appear in either ListMessageResponse or ListMessageSummaryResponse.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
messageId | Yes | string | The messageId of the message to dismiss |
Response Parameters
A response to a dismiss message request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
DismissMultipleMessagesRequest
{
"@class" : ".DismissMultipleMessagesRequest",
"messageIds" : [ "" ]
}
{
"@class" : ".DismissMultipleMessagesResponse",
"failedDismissals" : [ "" ],
"messagesDismissed" : 0,
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new DismissMultipleMessagesRequest()
.SetMessageIds(messageIds)
.Send((response) => {
IList<string> failedDismissals = response.FailedDismissals;
int? messagesDismissed = response.MessagesDismissed;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createDismissMultipleMessagesRequest()
.setMessageIds(messageIds)
.send(function(response:com.gamesparks.api.responses.DismissMultipleMessagesResponse):void {
var failedDismissals:Vector.<String> = response.getFailedDismissals();
var messagesDismissed:Number = response.getMessagesDismissed();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSDismissMultipleMessagesRequest* request = [[GSDismissMultipleMessagesRequest alloc] init];
[request setMessageIds:messageIds;
[request setCallback:^ (GSDismissMultipleMessagesResponse* response) {
NSArray* failedDismissals = [response getFailedDismissals];
NSNumber* messagesDismissed = [response getMessagesDismissed];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void DismissMultipleMessagesRequest_Response(GS& gsInstance, const DismissMultipleMessagesResponse& response) {
gsstl:vector<gsstl::string> failedDismissals = response.getFailedDismissals();
Optional::t_LongOptional messagesDismissed = response.getMessagesDismissed();
GSData scriptData = response.getScriptData();
}
......
DismissMultipleMessagesRequest request(gsInstance);
request.SetMessageIds(messageIds)
request.Send(DismissMultipleMessagesRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.DismissMultipleMessagesRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.DismissMultipleMessagesResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createDismissMultipleMessagesRequest()
.setMessageIds(messageIds)
.send(new GSEventListener<DismissMultipleMessagesResponse>() {
@Override
public void onEvent(DismissMultipleMessagesResponse response) {
List<String> failedDismissals = response.getFailedDismissals();
Integer messagesDismissed = response.getMessagesDismissed();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.DismissMultipleMessagesRequest();
request.messageIds = ...;
var response = request.Send();
var failedDismissals = response.failedDismissals;
var messagesDismissed = response.messagesDismissed;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createDismissMultipleMessagesRequest();
request.setMessageIds(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var failedDismissals = response.failedDismissals;
var messagesDismissed = response.messagesDismissed;
var scriptData = response.scriptData;
});
Allows multiple messages to be dismissed. Once dismissed the messages will no longer appear in either ListMessageResponse or ListMessageSummaryResponse.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
messageIds | No | string[] | The list of the messageIds to dismiss |
Response Parameters
A response to a dismiss message request
Parameter | Type | Description |
---|---|---|
failedDismissals | string[] | A list of the messageId values that were not dismissed |
messagesDismissed | number | An integer describing how many messages were dismissed |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
GetMessageRequest
{
"@class" : ".GetMessageRequest",
"messageId" : ""
}
{
"@class" : ".GetMessageResponse",
"message" : { },
"scriptData" : { },
"status" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetMessageRequest()
.SetMessageId(messageId)
.Send((response) => {
GSData message = response.Message;
GSData scriptData = response.ScriptData;
string status = response.Status;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetMessageRequest()
.setMessageId(messageId)
.send(function(response:com.gamesparks.api.responses.GetMessageResponse):void {
var message:Object = response.getMessage();
var scriptData:ScriptData = response.getScriptData();
var status:String = response.getStatus();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetMessageRequest* request = [[GSGetMessageRequest alloc] init];
[request setMessageId:messageId;
[request setCallback:^ (GSGetMessageResponse* response) {
NSDictionary* message = [response getMessage];
NSDictionary* scriptData = [response getScriptData];
NSString* status = [response getStatus];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetMessageRequest_Response(GS& gsInstance, const GetMessageResponse& response) {
GSData message = response.getMessage();
GSData scriptData = response.getScriptData();
gsstl::string status = response.getStatus();
}
......
GetMessageRequest request(gsInstance);
request.SetMessageId(messageId)
request.Send(GetMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetMessageRequest()
.setMessageId(messageId)
.send(new GSEventListener<GetMessageResponse>() {
@Override
public void onEvent(GetMessageResponse response) {
GSData message = response.getMessage();
GSData scriptData = response.getScriptData();
String status = response.getStatus();
}
});
var request = new SparkRequests.GetMessageRequest();
request.messageId = ...;
var response = request.Send();
var message = response.message;
var scriptData = response.scriptData;
var status = response.status;
var request = RTSession.newRequest().createGetMessageRequest();
request.setMessageId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var message = response.message;
var scriptData = response.scriptData;
var status = response.status;
});
Returns the full details of a message.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
messageId | Yes | string | The messageId of the message retreive |
Response Parameters
A response containing the message data for a given message
Parameter | Type | Description |
---|---|---|
message | JSON | The message data |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
status | string | The message status |
ListAchievementsRequest
{
"@class" : ".ListAchievementsRequest"
}
{
"@class" : ".ListAchievementsResponse",
"achievements" : [ {
"description" : "",
"earned" : false,
"name" : "",
"propertySet" : { },
"shortCode" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListAchievementsRequest()
.Send((response) => {
GSEnumerable<var> achievements = response.Achievements;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListAchievementsRequest()
.send(function(response:com.gamesparks.api.responses.ListAchievementsResponse):void {
var achievements:Vector.<Achievement> = response.getAchievements();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListAchievementsRequest* request = [[GSListAchievementsRequest alloc] init];
[request setCallback:^ (GSListAchievementsResponse* response) {
NSArray* achievements = [response getAchievements];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListAchievementsRequest_Response(GS& gsInstance, const ListAchievementsResponse& response) {
gsstl:vector<Types::Achievement*> achievements = response.getAchievements();
GSData scriptData = response.getScriptData();
}
......
ListAchievementsRequest request(gsInstance);
request.Send(ListAchievementsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListAchievementsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListAchievementsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListAchievementsRequest()
.send(new GSEventListener<ListAchievementsResponse>() {
@Override
public void onEvent(ListAchievementsResponse response) {
List<Achievement> achievements = response.getAchievements();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListAchievementsRequest();
var response = request.Send();
var achievements = response.achievements;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListAchievementsRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var achievements = response.achievements;
var scriptData = response.scriptData;
});
Retrieves a list of the configured achievements in the game, along with whether the current player has earned the achievement.
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A reponse containing the game’s achievments and an indication of whether the player has earned it
Parameter | Type | Description |
---|---|---|
achievements | Achievement[] | A list of JSON achievment objects |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListGameFriendsRequest
{
"@class" : ".ListGameFriendsRequest"
}
{
"@class" : ".ListGameFriendsResponse",
"friends" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListGameFriendsRequest()
.Send((response) => {
GSEnumerable<var> friends = response.Friends;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListGameFriendsRequest()
.send(function(response:com.gamesparks.api.responses.ListGameFriendsResponse):void {
var friends:Vector.<Player> = response.getFriends();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListGameFriendsRequest* request = [[GSListGameFriendsRequest alloc] init];
[request setCallback:^ (GSListGameFriendsResponse* response) {
NSArray* friends = [response getFriends];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListGameFriendsRequest_Response(GS& gsInstance, const ListGameFriendsResponse& response) {
gsstl:vector<Types::Player*> friends = response.getFriends();
GSData scriptData = response.getScriptData();
}
......
ListGameFriendsRequest request(gsInstance);
request.Send(ListGameFriendsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListGameFriendsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListGameFriendsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListGameFriendsRequest()
.send(new GSEventListener<ListGameFriendsResponse>() {
@Override
public void onEvent(ListGameFriendsResponse response) {
List<Player> friends = response.getFriends();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListGameFriendsRequest();
var response = request.Send();
var friends = response.friends;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListGameFriendsRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var friends = response.friends;
var scriptData = response.scriptData;
});
Returns the list of the current players game friends.
A Game friend is someone in their social network who also plays the game.
Against each friend, an indicator is supplied to show whether the friend is currently connected to the GameSparks service
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing the list of the current players game friends.
Parameter | Type | Description |
---|---|---|
friends | Player[] | A list of JSON objects containing game friend data |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListInviteFriendsRequest
{
"@class" : ".ListInviteFriendsRequest"
}
{
"@class" : ".ListInviteFriendsResponse",
"friends" : [ {
"displayName" : "",
"id" : "",
"profilePic" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListInviteFriendsRequest()
.Send((response) => {
GSEnumerable<var> friends = response.Friends;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListInviteFriendsRequest()
.send(function(response:com.gamesparks.api.responses.ListInviteFriendsResponse):void {
var friends:Vector.<InvitableFriend> = response.getFriends();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListInviteFriendsRequest* request = [[GSListInviteFriendsRequest alloc] init];
[request setCallback:^ (GSListInviteFriendsResponse* response) {
NSArray* friends = [response getFriends];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListInviteFriendsRequest_Response(GS& gsInstance, const ListInviteFriendsResponse& response) {
gsstl:vector<Types::InvitableFriend*> friends = response.getFriends();
GSData scriptData = response.getScriptData();
}
......
ListInviteFriendsRequest request(gsInstance);
request.Send(ListInviteFriendsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListInviteFriendsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListInviteFriendsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListInviteFriendsRequest()
.send(new GSEventListener<ListInviteFriendsResponse>() {
@Override
public void onEvent(ListInviteFriendsResponse response) {
List<InvitableFriend> friends = response.getFriends();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListInviteFriendsRequest();
var response = request.Send();
var friends = response.friends;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListInviteFriendsRequest();
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var friends = response.friends;
var scriptData = response.scriptData;
});
Returns the list of the current players friends in their social network, who are not yet playing this game.
This is dependent on the security and privacy policies of the social network.
For example, Facebook’s policies prevent this friend list being provided, whereas Twitter will supply a list of users who are not playing the game.
Request Parameters
Parameter | Required | Type | Description |
---|
Response Parameters
A response containing a list of non game friends.
Parameter | Type | Description |
---|---|---|
friends | InvitableFriend[] | A list of JSON objects containing game friend data |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListMessageDetailRequest
{
"@class" : ".ListMessageDetailRequest",
"entryCount" : 0,
"include" : "",
"offset" : 0,
"status" : ""
}
{
"@class" : ".ListMessageDetailResponse",
"messageList" : [ {
"id" : "",
"message" : { },
"seen" : false,
"status" : "",
"when" : "2018-07-11T14:02Z"
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListMessageDetailRequest()
.SetEntryCount(entryCount)
.SetInclude(include)
.SetOffset(offset)
.SetStatus(status)
.Send((response) => {
GSEnumerable<var> messageList = response.MessageList;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListMessageDetailRequest()
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.setStatus(status)
.send(function(response:com.gamesparks.api.responses.ListMessageDetailResponse):void {
var messageList:Vector.<PlayerMessage> = response.getMessageList();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListMessageDetailRequest* request = [[GSListMessageDetailRequest alloc] init];
[request setEntryCount:entryCount;
[request setInclude:include;
[request setOffset:offset;
[request setStatus:status;
[request setCallback:^ (GSListMessageDetailResponse* response) {
NSArray* messageList = [response getMessageList];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListMessageDetailRequest_Response(GS& gsInstance, const ListMessageDetailResponse& response) {
gsstl:vector<Types::PlayerMessage*> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
......
ListMessageDetailRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetInclude(include)
request.SetOffset(offset)
request.SetStatus(status)
request.Send(ListMessageDetailRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListMessageDetailRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListMessageDetailResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListMessageDetailRequest()
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.setStatus(status)
.send(new GSEventListener<ListMessageDetailResponse>() {
@Override
public void onEvent(ListMessageDetailResponse response) {
List<PlayerMessage> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListMessageDetailRequest();
request.entryCount = ...;
request.include = ...;
request.offset = ...;
request.status = ...;
var response = request.Send();
var messageList = response.messageList;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListMessageDetailRequest();
request.setEntryCount(...);
request.setInclude(...);
request.setOffset(...);
request.setStatus(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var messageList = response.messageList;
var scriptData = response.scriptData;
});
Returns the list of the current player’s messages / notifications.
The list only contains un-dismissed messages, to dismiss a message see DismissMessageRequest Read the section on Messages to see the complete list of messages and their meaning.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of items to return in a page (default=50) |
include | No | string | An optional filter that limits the message types returned |
offset | No | number | The offset (page number) to start from (default=0) |
status | No | string | The status of messages to be retrieved. If omitted, messages of all statuses will be retrieved |
Response Parameters
A response containing the list of the current players messages / notifications.
Parameter | Type | Description |
---|---|---|
messageList | PlayerMessage[] | A list of JSON objects containing player messages |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListMessageRequest
{
"@class" : ".ListMessageRequest",
"entryCount" : 0,
"include" : "",
"offset" : 0
}
{
"@class" : ".ListMessageResponse",
"messageList" : [ { } ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListMessageRequest()
.SetEntryCount(entryCount)
.SetInclude(include)
.SetOffset(offset)
.Send((response) => {
IList<GSData> messageList = response.MessageList;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListMessageRequest()
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.send(function(response:com.gamesparks.api.responses.ListMessageResponse):void {
var messageList:Vector.<Object> = response.getMessageList();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListMessageRequest* request = [[GSListMessageRequest alloc] init];
[request setEntryCount:entryCount;
[request setInclude:include;
[request setOffset:offset;
[request setCallback:^ (GSListMessageResponse* response) {
NSArray* messageList = [response getMessageList];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListMessageRequest_Response(GS& gsInstance, const ListMessageResponse& response) {
gsstl:vector<GSData> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
......
ListMessageRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetInclude(include)
request.SetOffset(offset)
request.Send(ListMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListMessageRequest()
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.send(new GSEventListener<ListMessageResponse>() {
@Override
public void onEvent(ListMessageResponse response) {
List<GSData> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListMessageRequest();
request.entryCount = ...;
request.include = ...;
request.offset = ...;
var response = request.Send();
var messageList = response.messageList;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListMessageRequest();
request.setEntryCount(...);
request.setInclude(...);
request.setOffset(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var messageList = response.messageList;
var scriptData = response.scriptData;
});
Returns the list of the current player’s messages / notifications.
The list only contains un-dismissed messages, to dismiss a message see DismissMessageRequest Read the section on Messages to see the complete list of messages and their meaning.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of items to return in a page (default=50) |
include | No | string | An optional filter that limits the message types returned |
offset | No | number | The offset (page number) to start from (default=0) |
Response Parameters
A response containing the list of the current players messages / notifications.
Parameter | Type | Description |
---|---|---|
messageList | JSON[] | A list of JSON objects containing player messages |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListMessageSummaryRequest
{
"@class" : ".ListMessageSummaryRequest",
"entryCount" : 0,
"offset" : 0
}
{
"@class" : ".ListMessageSummaryResponse",
"messageList" : [ { } ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListMessageSummaryRequest()
.SetEntryCount(entryCount)
.SetOffset(offset)
.Send((response) => {
IList<GSData> messageList = response.MessageList;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListMessageSummaryRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.send(function(response:com.gamesparks.api.responses.ListMessageSummaryResponse):void {
var messageList:Vector.<Object> = response.getMessageList();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListMessageSummaryRequest* request = [[GSListMessageSummaryRequest alloc] init];
[request setEntryCount:entryCount;
[request setOffset:offset;
[request setCallback:^ (GSListMessageSummaryResponse* response) {
NSArray* messageList = [response getMessageList];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListMessageSummaryRequest_Response(GS& gsInstance, const ListMessageSummaryResponse& response) {
gsstl:vector<GSData> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
......
ListMessageSummaryRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetOffset(offset)
request.Send(ListMessageSummaryRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListMessageSummaryRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListMessageSummaryResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListMessageSummaryRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.send(new GSEventListener<ListMessageSummaryResponse>() {
@Override
public void onEvent(ListMessageSummaryResponse response) {
List<GSData> messageList = response.getMessageList();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListMessageSummaryRequest();
request.entryCount = ...;
request.offset = ...;
var response = request.Send();
var messageList = response.messageList;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListMessageSummaryRequest();
request.setEntryCount(...);
request.setOffset(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var messageList = response.messageList;
var scriptData = response.scriptData;
});
Returns a summary of the list of the current players messages / notifications.
The list only contains un-dismissed messages, to dismiss a message see DismissMessageRequest.
The full message can be retrieved using GetMessageRequest Read the section on Messages to see the complete list of messages and their meanings.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of items to return in a page (default=50) |
offset | No | number | The offset (page number) to start from (default=0) |
Response Parameters
A response containing a summary of the list of the current players messages / notifications.
Parameter | Type | Description |
---|---|---|
messageList | JSON[] | A list of JSON objects containing player message summaries |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListTransactionsRequest
{
"@class" : ".ListTransactionsRequest",
"dateFrom" : "2018-07-11T14:02Z",
"dateTo" : "2018-07-11T14:02Z",
"entryCount" : 0,
"include" : "",
"offset" : 0
}
{
"@class" : ".ListTransactionsResponse",
"scriptData" : { },
"transactionList" : [ {
"items" : [ {
"amount" : 0,
"newValue" : 0,
"type" : ""
} ],
"originalRequestId" : "",
"playerId" : "",
"reason" : "",
"revokeDate" : "2018-07-11T14:02Z",
"revoked" : false,
"script" : "",
"scriptType" : "",
"transactionId" : "",
"when" : "2018-07-11T14:02Z"
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListTransactionsRequest()
.SetDateFrom(dateFrom)
.SetDateTo(dateTo)
.SetEntryCount(entryCount)
.SetInclude(include)
.SetOffset(offset)
.Send((response) => {
GSData scriptData = response.ScriptData;
GSEnumerable<var> transactionList = response.TransactionList;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListTransactionsRequest()
.setDateFrom(dateFrom)
.setDateTo(dateTo)
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.send(function(response:com.gamesparks.api.responses.ListTransactionsResponse):void {
var scriptData:ScriptData = response.getScriptData();
var transactionList:Vector.<PlayerTransaction> = response.getTransactionList();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListTransactionsRequest* request = [[GSListTransactionsRequest alloc] init];
[request setDateFrom:dateFrom;
[request setDateTo:dateTo;
[request setEntryCount:entryCount;
[request setInclude:include;
[request setOffset:offset;
[request setCallback:^ (GSListTransactionsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionList = [response getTransactionList];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListTransactionsRequest_Response(GS& gsInstance, const ListTransactionsResponse& response) {
GSData scriptData = response.getScriptData();
gsstl:vector<Types::PlayerTransaction*> transactionList = response.getTransactionList();
}
......
ListTransactionsRequest request(gsInstance);
request.SetDateFrom(dateFrom)
request.SetDateTo(dateTo)
request.SetEntryCount(entryCount)
request.SetInclude(include)
request.SetOffset(offset)
request.Send(ListTransactionsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListTransactionsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListTransactionsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListTransactionsRequest()
.setDateFrom(dateFrom)
.setDateTo(dateTo)
.setEntryCount(entryCount)
.setInclude(include)
.setOffset(offset)
.send(new GSEventListener<ListTransactionsResponse>() {
@Override
public void onEvent(ListTransactionsResponse response) {
GSData scriptData = response.getScriptData();
List<PlayerTransaction> transactionList = response.getTransactionList();
}
});
var request = new SparkRequests.ListTransactionsRequest();
request.dateFrom = ...;
request.dateTo = ...;
request.entryCount = ...;
request.include = ...;
request.offset = ...;
var response = request.Send();
var scriptData = response.scriptData;
var transactionList = response.transactionList;
var request = RTSession.newRequest().createListTransactionsRequest();
request.setDateFrom(...);
request.setDateTo(...);
request.setEntryCount(...);
request.setInclude(...);
request.setOffset(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var transactionList = response.transactionList;
});
Returns a list of the current player’s transaction history.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
dateFrom | No | date | Optional date constraint to list transactions from |
dateTo | No | date | Optional date constraint to list transactions to |
entryCount | No | number | The number of items to return in a page (default=50) |
include | No | string | An optional filter that limits the transaction types returned |
offset | No | number | The offset (page number) to start from (default=0) |
Response Parameters
A response listing transactions for the player
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionList | PlayerTransaction[] | A list of JSON objects containing player transactions |
LogEventRequest
{
"@class" : ".LogEventRequest",
"eventKey" : ""
}
{
"@class" : ".LogEventResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new LogEventRequest()
.SetEventKey(eventKey)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createLogEventRequest()
.setEventKey(eventKey)
.send(function(response:com.gamesparks.api.responses.LogEventResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSLogEventRequest* request = [[GSLogEventRequest alloc] init];
[request setEventKey:eventKey;
[request setCallback:^ (GSLogEventResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void LogEventRequest_Response(GS& gsInstance, const LogEventResponse& response) {
GSData scriptData = response.getScriptData();
}
......
LogEventRequest request(gsInstance);
request.SetEventKey(eventKey)
request.Send(LogEventRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LogEventRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LogEventResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createLogEventRequest()
.setEventKey(eventKey)
.send(new GSEventListener<LogEventResponse>() {
@Override
public void onEvent(LogEventResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.LogEventRequest();
request.eventKey = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createLogEventRequest();
request.setEventKey(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a user defined event to be triggered.
This call differs from most as it does not have a fixed format. The @class and eventKey attributes are common, but the rest of the attributes are as defined in the Event object configured in the dev portal.
The example below shows a request to an event with a short code of HS with 2 attributes, 'HS’ & 'GL’.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
eventKey | Yes | string | The short code of the event to trigger |
Response Parameters
A response to a log event request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
SendFriendMessageRequest
{
"@class" : ".SendFriendMessageRequest",
"friendIds" : [ "" ],
"message" : ""
}
{
"@class" : ".SendFriendMessageResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SendFriendMessageRequest()
.SetFriendIds(friendIds)
.SetMessage(message)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSendFriendMessageRequest()
.setFriendIds(friendIds)
.setMessage(message)
.send(function(response:com.gamesparks.api.responses.SendFriendMessageResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSendFriendMessageRequest* request = [[GSSendFriendMessageRequest alloc] init];
[request setFriendIds:friendIds;
[request setMessage:message;
[request setCallback:^ (GSSendFriendMessageResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SendFriendMessageRequest_Response(GS& gsInstance, const SendFriendMessageResponse& response) {
GSData scriptData = response.getScriptData();
}
......
SendFriendMessageRequest request(gsInstance);
request.SetFriendIds(friendIds)
request.SetMessage(message)
request.Send(SendFriendMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SendFriendMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SendFriendMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSendFriendMessageRequest()
.setFriendIds(friendIds)
.setMessage(message)
.send(new GSEventListener<SendFriendMessageResponse>() {
@Override
public void onEvent(SendFriendMessageResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.SendFriendMessageRequest();
request.friendIds = ...;
request.message = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createSendFriendMessageRequest();
request.setFriendIds(...);
request.setMessage(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Sends a message to one or more game friend(s). A game friend is someone in the players social network who also plays the game.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
friendIds | Yes | string[] | One or more friend ID’s. This can be supplied as a single string, or a JSON array |
message | Yes | string | The message to send |
Response Parameters
A response to a send friend message request.
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
friendId | NOT_FRIEND | The friend ID passed is not linked to the current player as a game friend |
friendId | INVALID | The value passed is not a valid ID |
SocialDisconnectRequest
{
"@class" : ".SocialDisconnectRequest",
"systemId" : ""
}
{
"@class" : ".SocialDisconnectResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SocialDisconnectRequest()
.SetSystemId(systemId)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSocialDisconnectRequest()
.setSystemId(systemId)
.send(function(response:com.gamesparks.api.responses.SocialDisconnectResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSocialDisconnectRequest* request = [[GSSocialDisconnectRequest alloc] init];
[request setSystemId:systemId;
[request setCallback:^ (GSSocialDisconnectResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SocialDisconnectRequest_Response(GS& gsInstance, const SocialDisconnectResponse& response) {
GSData scriptData = response.getScriptData();
}
......
SocialDisconnectRequest request(gsInstance);
request.SetSystemId(systemId)
request.Send(SocialDisconnectRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SocialDisconnectRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SocialDisconnectResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSocialDisconnectRequest()
.setSystemId(systemId)
.send(new GSEventListener<SocialDisconnectResponse>() {
@Override
public void onEvent(SocialDisconnectResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.SocialDisconnectRequest();
request.systemId = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createSocialDisconnectRequest();
request.setSystemId(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a player’s internal profile to be disconnected from an external system to which it is linked. Any friends linked as result of this connection will be removed.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
systemId | No | string | The external system from which to disconnect this profile, supplied as a two letter ID. The options are: {FACEBOOK:FB, AMAZON:AM, GAME_CENTER:GC |
Response Parameters
A response to a SocialDisconnectRequest
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
systemId | REQUIRED | A systemId from which to disconnect must be provided |
systemId | NOT_CONNECTED | The player does not have a connection with the provided system. |
userName | CHANGE_REQUIRED | If the player’s userName was derived from the profile they are disconnecting from, they must change it before they can disconnect. The userName can be changed via a ChangeUserDetailsRequest. |
password | NOT_SET | Before disconnecting, if the player has no other connected profiles then they must have a password set in order to be able to authenticate in the future. A password can be set via a ChangeUserDetailsRequest. |
UpdateMessageRequest
{
"@class" : ".UpdateMessageRequest",
"messageId" : "",
"status" : ""
}
{
"@class" : ".UpdateMessageResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new UpdateMessageRequest()
.SetMessageId(messageId)
.SetStatus(status)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createUpdateMessageRequest()
.setMessageId(messageId)
.setStatus(status)
.send(function(response:com.gamesparks.api.responses.UpdateMessageResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSUpdateMessageRequest* request = [[GSUpdateMessageRequest alloc] init];
[request setMessageId:messageId;
[request setStatus:status;
[request setCallback:^ (GSUpdateMessageResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void UpdateMessageRequest_Response(GS& gsInstance, const UpdateMessageResponse& response) {
GSData scriptData = response.getScriptData();
}
......
UpdateMessageRequest request(gsInstance);
request.SetMessageId(messageId)
request.SetStatus(status)
request.Send(UpdateMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.UpdateMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.UpdateMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createUpdateMessageRequest()
.setMessageId(messageId)
.setStatus(status)
.send(new GSEventListener<UpdateMessageResponse>() {
@Override
public void onEvent(UpdateMessageResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.UpdateMessageRequest();
request.messageId = ...;
request.status = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createUpdateMessageRequest();
request.setMessageId(...);
request.setStatus(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a message status to be updated.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
messageId | Yes | string | The messageId of the message to update |
status | Yes | string | The status to set on the message |
Response Parameters
A response to an update message request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Store
AmazonBuyGoodsRequest
{
"@class" : ".AmazonBuyGoodsRequest",
"amazonUserId" : "",
"currencyCode" : "",
"receiptId" : "",
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AmazonBuyGoodsRequest()
.SetAmazonUserId(amazonUserId)
.SetCurrencyCode(currencyCode)
.SetReceiptId(receiptId)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAmazonBuyGoodsRequest()
.setAmazonUserId(amazonUserId)
.setCurrencyCode(currencyCode)
.setReceiptId(receiptId)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAmazonBuyGoodsRequest* request = [[GSAmazonBuyGoodsRequest alloc] init];
[request setAmazonUserId:amazonUserId;
[request setCurrencyCode:currencyCode;
[request setReceiptId:receiptId;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AmazonBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
AmazonBuyGoodsRequest request(gsInstance);
request.SetAmazonUserId(amazonUserId)
request.SetCurrencyCode(currencyCode)
request.SetReceiptId(receiptId)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.Send(AmazonBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AmazonBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAmazonBuyGoodsRequest()
.setAmazonUserId(amazonUserId)
.setCurrencyCode(currencyCode)
.setReceiptId(receiptId)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.AmazonBuyGoodsRequest();
request.amazonUserId = ...;
request.currencyCode = ...;
request.receiptId = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createAmazonBuyGoodsRequest();
request.setAmazonUserId(...);
request.setCurrencyCode(...);
request.setReceiptId(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes the receipt from an Amazon in app purchase.
The GameSparks platform will validate the amazonUserId and receiptId with Amazon using the Amazon Purchase Secret configured against the game.
The receiptId in the data will be recorded and the request will be rejected if the receiptId has previously been processed, this prevents replay attacks.
Once verfied, the players account will be credited with the Virtual Good, or Virtual Currency the purchase contains. The virtual good will be looked up by matching the productId in the receipt with the 'Amazon Product Id’ configured against the virtual good.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
amazonUserId | Yes | string | The userId obtained from the UserData within a PurchaseResponse |
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
receiptId | Yes | string | The receiptId obtained from the Receipt within a PurchaseResponse |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
receiptId | REQUIRED | The receiptId is missing |
amazonUserId | REQUIRED | The amazonUserId is missing |
verificationError | 1 | No matching virtual good can be found |
verificationError | 2 | The receiptId is not valid for the given userId and secret |
verificationError | 3 | There was an error connecting to the Amazon service |
verificationError | 4 | The Amazon purchase secret is not configured against the game |
verificationError | 5 | The receiptId has previously been processed |
BuyVirtualGoodsRequest
{
"@class" : ".BuyVirtualGoodsRequest",
"currencyShortCode" : "",
"currencyType" : 0,
"quantity" : 0,
"shortCode" : ""
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new BuyVirtualGoodsRequest()
.SetCurrencyShortCode(currencyShortCode)
.SetCurrencyType(currencyType)
.SetQuantity(quantity)
.SetShortCode(shortCode)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createBuyVirtualGoodsRequest()
.setCurrencyShortCode(currencyShortCode)
.setCurrencyType(currencyType)
.setQuantity(quantity)
.setShortCode(shortCode)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSBuyVirtualGoodsRequest* request = [[GSBuyVirtualGoodsRequest alloc] init];
[request setCurrencyShortCode:currencyShortCode;
[request setCurrencyType:currencyType;
[request setQuantity:quantity;
[request setShortCode:shortCode;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void BuyVirtualGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
BuyVirtualGoodsRequest request(gsInstance);
request.SetCurrencyShortCode(currencyShortCode)
request.SetCurrencyType(currencyType)
request.SetQuantity(quantity)
request.SetShortCode(shortCode)
request.Send(BuyVirtualGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.BuyVirtualGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createBuyVirtualGoodsRequest()
.setCurrencyShortCode(currencyShortCode)
.setCurrencyType(currencyType)
.setQuantity(quantity)
.setShortCode(shortCode)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.BuyVirtualGoodsRequest();
request.currencyShortCode = ...;
request.currencyType = ...;
request.quantity = ...;
request.shortCode = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createBuyVirtualGoodsRequest();
request.setCurrencyShortCode(...);
request.setCurrencyType(...);
request.setQuantity(...);
request.setShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Purchases a virtual good with an in game currency. Once purchased the virtual good will be added to the players account.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
currencyShortCode | No | string | The short code of the currency to use |
currencyType | No | number | Which virtual currency to use. (1 to 6) |
quantity | Yes | number | The number of items to purchase |
shortCode | Yes | string | The short code of the virtual good to be purchased |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
currencyType | UNRECOGNISED | Not a valid currency, valid values are 1 to 6 |
virtualGood | CANNOT_BE_CURRENCY | The player cannot buy a currency pack with virtual currency |
currency1 | INSUFFICIENT_FUNDS | The player does not have enough currency 1 funds to complete the purchase |
currency2 | INSUFFICIENT_FUNDS | The player does not have enough currency 2 funds to complete the purchase |
currency3 | INSUFFICIENT_FUNDS | The player does not have enough currency 3 funds to complete the purchase |
currency4 | INSUFFICIENT_FUNDS | The player does not have enough currency 4 funds to complete the purchase |
currency5 | INSUFFICIENT_FUNDS | The player does not have enough currency 5 funds to complete the purchase |
currency6 | INSUFFICIENT_FUNDS | The player does not have enough currency 6 funds to complete the purchase |
shortCode | UNKNOWN | The shortCode supplied does not match a VirtualGood |
shortCode | DISABLED | The VirtualGood requested is marked as disabled |
quantity | EXCEEDS_MAX_QUANTITY | The requst would cause the player to exceed to maxQty of this VirtualGood |
currencyShortCode | UNRECOGNISED | Not a valid currency |
ConsumeVirtualGoodRequest
{
"@class" : ".ConsumeVirtualGoodRequest",
"quantity" : 0,
"shortCode" : ""
}
{
"@class" : ".ConsumeVirtualGoodResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ConsumeVirtualGoodRequest()
.SetQuantity(quantity)
.SetShortCode(shortCode)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createConsumeVirtualGoodRequest()
.setQuantity(quantity)
.setShortCode(shortCode)
.send(function(response:com.gamesparks.api.responses.ConsumeVirtualGoodResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSConsumeVirtualGoodRequest* request = [[GSConsumeVirtualGoodRequest alloc] init];
[request setQuantity:quantity;
[request setShortCode:shortCode;
[request setCallback:^ (GSConsumeVirtualGoodResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ConsumeVirtualGoodRequest_Response(GS& gsInstance, const ConsumeVirtualGoodResponse& response) {
GSData scriptData = response.getScriptData();
}
......
ConsumeVirtualGoodRequest request(gsInstance);
request.SetQuantity(quantity)
request.SetShortCode(shortCode)
request.Send(ConsumeVirtualGoodRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ConsumeVirtualGoodRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ConsumeVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createConsumeVirtualGoodRequest()
.setQuantity(quantity)
.setShortCode(shortCode)
.send(new GSEventListener<ConsumeVirtualGoodResponse>() {
@Override
public void onEvent(ConsumeVirtualGoodResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ConsumeVirtualGoodRequest();
request.quantity = ...;
request.shortCode = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createConsumeVirtualGoodRequest();
request.setQuantity(...);
request.setShortCode(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Consumes a given amount of the specified virtual good.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
quantity | Yes | number | The amount of virtual goods to be consumed |
shortCode | Yes | string | The short code of the virtual good to be consumed |
Response Parameters
A response to a consume virtual goods response
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
qty | INSUFFICIENT | The player does not have sufficient virtual goods for shortcode specified |
GooglePlayBuyGoodsRequest
{
"@class" : ".GooglePlayBuyGoodsRequest",
"currencyCode" : "",
"signature" : "",
"signedData" : "",
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GooglePlayBuyGoodsRequest()
.SetCurrencyCode(currencyCode)
.SetSignature(signature)
.SetSignedData(signedData)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGooglePlayBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setSignature(signature)
.setSignedData(signedData)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGooglePlayBuyGoodsRequest* request = [[GSGooglePlayBuyGoodsRequest alloc] init];
[request setCurrencyCode:currencyCode;
[request setSignature:signature;
[request setSignedData:signedData;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GooglePlayBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
GooglePlayBuyGoodsRequest request(gsInstance);
request.SetCurrencyCode(currencyCode)
request.SetSignature(signature)
request.SetSignedData(signedData)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.Send(GooglePlayBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GooglePlayBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGooglePlayBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setSignature(signature)
.setSignedData(signedData)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.GooglePlayBuyGoodsRequest();
request.currencyCode = ...;
request.signature = ...;
request.signedData = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createGooglePlayBuyGoodsRequest();
request.setCurrencyCode(...);
request.setSignature(...);
request.setSignedData(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes the response from a Google Play in app purchase flow.
The GameSparks platform will validate the signature and signed data with the Google Play Public Key configured against the game.
The orderId in the data will be recorded and the request will be rejected if the orderId has previously been processed, this prevents replay attacks.
Once verfied, the players account will be credited with the Virtual Good, or Virtual Currency the purchase contains. The virtual good will be looked up by matching the productId in the signed data with the 'Google Product ID’ configured against the virtual good.
It is critical that the signedData is sent exactly as it is returned form google, including any whitespace. Any modification of the signedData will cause the verification process to fail.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
signature | Yes | string | The value obtained from data.getStringExtra(“INAPP_DATA_SIGNATURE”); |
signedData | Yes | string | The value obtained from data.getStringExtra(“INAPP_PURCHASE_DATA”) |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
verificationError | 5 | The orderId in the signedData has previously been processed |
verificationError | 4 | The google play public key is not configured against the game |
verificationError | 3 | There was an error connecting to the google play service |
verificationError | 2 | The signature does not match the signed data |
verificationError | 1 | No matching virtual good can be found |
IOSBuyGoodsRequest
{
"@class" : ".IOSBuyGoodsRequest",
"currencyCode" : "",
"receipt" : "",
"sandbox" : false,
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new IOSBuyGoodsRequest()
.SetCurrencyCode(currencyCode)
.SetReceipt(receipt)
.SetSandbox(sandbox)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createIOSBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setReceipt(receipt)
.setSandbox(sandbox)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSIOSBuyGoodsRequest* request = [[GSIOSBuyGoodsRequest alloc] init];
[request setCurrencyCode:currencyCode;
[request setReceipt:receipt;
[request setSandbox:sandbox;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void IOSBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
IOSBuyGoodsRequest request(gsInstance);
request.SetCurrencyCode(currencyCode)
request.SetReceipt(receipt)
request.SetSandbox(sandbox)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.Send(IOSBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.IOSBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createIOSBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setReceipt(receipt)
.setSandbox(sandbox)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.IOSBuyGoodsRequest();
request.currencyCode = ...;
request.receipt = ...;
request.sandbox = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createIOSBuyGoodsRequest();
request.setCurrencyCode(...);
request.setReceipt(...);
request.setSandbox(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes a transaction receipt from an App Store in app purchase.
The GameSparks platform will validate the receipt with Apple and process the response. The transaction_id in the response will be recorded and the request will be rejected if the transaction_id has previously been processed, this prevents replay attacks.
Once verified, the players account will be credited with the Virtual Good, or Virtual Currency the purchase contains. The virtual good will be looked up by matching the product_id in the response with the 'IOS Product ID’ configured against the virtual good.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
receipt | Yes | string | The receipt obtained from SKPaymentTransaction. transactionReceipt |
sandbox | No | boolean | Should the sandbox account be used |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
verificationError | 1 | No matching virtual good can be found |
verificationError | 2 | The Apple servers failed to verify the receipt |
verificationError | 3 | There was an error connecting to the Apple server |
verificationError | 5 | The transaction_id has been processed before |
ListVirtualGoodsRequest
{
"@class" : ".ListVirtualGoodsRequest",
"includeDisabled" : false,
"tags" : [ "" ]
}
{
"@class" : ".ListVirtualGoodsResponse",
"scriptData" : { },
"virtualGoods" : [ {
"WP8StoreProductId" : "",
"amazonStoreProductId" : "",
"baseCurrency1Cost" : 0,
"baseCurrency2Cost" : 0,
"baseCurrency3Cost" : 0,
"baseCurrency4Cost" : 0,
"baseCurrency5Cost" : 0,
"baseCurrency6Cost" : 0,
"baseCurrencyCosts" : { },
"bundledGoods" : [ {
"qty" : 0,
"shortCode" : ""
} ],
"currency1Cost" : 0,
"currency2Cost" : 0,
"currency3Cost" : 0,
"currency4Cost" : 0,
"currency5Cost" : 0,
"currency6Cost" : 0,
"currencyCosts" : { },
"description" : "",
"disabled" : false,
"googlePlayProductId" : "",
"iosAppStoreProductId" : "",
"maxQuantity" : 0,
"name" : "",
"propertySet" : { },
"psnStoreProductId" : "",
"segmentedCurrency1Cost" : 0,
"segmentedCurrency2Cost" : 0,
"segmentedCurrency3Cost" : 0,
"segmentedCurrency4Cost" : 0,
"segmentedCurrency5Cost" : 0,
"segmentedCurrency6Cost" : 0,
"segmentedCurrencyCosts" : { },
"shortCode" : "",
"steamStoreProductId" : "",
"tags" : "",
"type" : "",
"w8StoreProductId" : ""
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListVirtualGoodsRequest()
.SetIncludeDisabled(includeDisabled)
.SetTags(tags)
.Send((response) => {
GSData scriptData = response.ScriptData;
GSEnumerable<var> virtualGoods = response.VirtualGoods;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListVirtualGoodsRequest()
.setIncludeDisabled(includeDisabled)
.setTags(tags)
.send(function(response:com.gamesparks.api.responses.ListVirtualGoodsResponse):void {
var scriptData:ScriptData = response.getScriptData();
var virtualGoods:Vector.<VirtualGood> = response.getVirtualGoods();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListVirtualGoodsRequest* request = [[GSListVirtualGoodsRequest alloc] init];
[request setIncludeDisabled:includeDisabled;
[request setTags:tags;
[request setCallback:^ (GSListVirtualGoodsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSArray* virtualGoods = [response getVirtualGoods];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListVirtualGoodsRequest_Response(GS& gsInstance, const ListVirtualGoodsResponse& response) {
GSData scriptData = response.getScriptData();
gsstl:vector<Types::VirtualGood*> virtualGoods = response.getVirtualGoods();
}
......
ListVirtualGoodsRequest request(gsInstance);
request.SetIncludeDisabled(includeDisabled)
request.SetTags(tags)
request.Send(ListVirtualGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListVirtualGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListVirtualGoodsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListVirtualGoodsRequest()
.setIncludeDisabled(includeDisabled)
.setTags(tags)
.send(new GSEventListener<ListVirtualGoodsResponse>() {
@Override
public void onEvent(ListVirtualGoodsResponse response) {
GSData scriptData = response.getScriptData();
List<VirtualGood> virtualGoods = response.getVirtualGoods();
}
});
var request = new SparkRequests.ListVirtualGoodsRequest();
request.includeDisabled = ...;
request.tags = ...;
var response = request.Send();
var scriptData = response.scriptData;
var virtualGoods = response.virtualGoods;
var request = RTSession.newRequest().createListVirtualGoodsRequest();
request.setIncludeDisabled(...);
request.setTags(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var virtualGoods = response.virtualGoods;
});
Returns the list of configured virtual goods.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
includeDisabled | No | boolean | If true, the returned list will include disabled VirtualVoods |
tags | No | string[] | A filter to only include goods with the given tags. Each good must have all the provided tags. |
Response Parameters
A response containing the list of configured virtual goods.
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
virtualGoods | VirtualGood[] | A list of JSON objects containing virtual goods data |
PsnBuyGoodsRequest
{
"@class" : ".PsnBuyGoodsRequest",
"authorizationCode" : "",
"currencyCode" : "",
"entitlementLabel" : "",
"redirectUri" : "",
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false,
"useCount" : 0
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new PsnBuyGoodsRequest()
.SetAuthorizationCode(authorizationCode)
.SetCurrencyCode(currencyCode)
.SetEntitlementLabel(entitlementLabel)
.SetRedirectUri(redirectUri)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.SetUseCount(useCount)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createPsnBuyGoodsRequest()
.setAuthorizationCode(authorizationCode)
.setCurrencyCode(currencyCode)
.setEntitlementLabel(entitlementLabel)
.setRedirectUri(redirectUri)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.setUseCount(useCount)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSPsnBuyGoodsRequest* request = [[GSPsnBuyGoodsRequest alloc] init];
[request setAuthorizationCode:authorizationCode;
[request setCurrencyCode:currencyCode;
[request setEntitlementLabel:entitlementLabel;
[request setRedirectUri:redirectUri;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setUseCount:useCount;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void PsnBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
PsnBuyGoodsRequest request(gsInstance);
request.SetAuthorizationCode(authorizationCode)
request.SetCurrencyCode(currencyCode)
request.SetEntitlementLabel(entitlementLabel)
request.SetRedirectUri(redirectUri)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.SetUseCount(useCount)
request.Send(PsnBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.PsnBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createPsnBuyGoodsRequest()
.setAuthorizationCode(authorizationCode)
.setCurrencyCode(currencyCode)
.setEntitlementLabel(entitlementLabel)
.setRedirectUri(redirectUri)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.setUseCount(useCount)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.PsnBuyGoodsRequest();
request.authorizationCode = ...;
request.currencyCode = ...;
request.entitlementLabel = ...;
request.redirectUri = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
request.useCount = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createPsnBuyGoodsRequest();
request.setAuthorizationCode(...);
request.setCurrencyCode(...);
request.setEntitlementLabel(...);
request.setRedirectUri(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
request.setUseCount(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes an update of entitlement in PlayStation network.
The GameSparks platform will update the 'use_count’ for an entitlement (by default 'use_count’ is 1).
The request will be rejected if entitlement 'use_limit’ is 0
GampSparks platform by default will use internally saved PSN user access token
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
authorizationCode | No | string | The authorization code obtained from PSN, as described here https://ps4.scedev.net/resources/documents/SDK/latest/NpAuth-Reference/0008.html |
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
entitlementLabel | Yes | string | Specify the entitlement label of the entitlement to update. (Not an entitlement ID). |
redirectUri | No | string | When using the authorization code obtained from PlayStation®4/PlayStation®Vita/PlayStation®3, this is not required. |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
useCount | No | number | Optional - specify the quantity of the entitlement to use. Default = 1 |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
verificationError | 1 | No matching virtual good can be found |
verificationError | 2 | The PSN servers failed to verify the entitlementLabel |
verificationError | 3 | There was an error connecting to the PSN server |
SteamBuyGoodsRequest
{
"@class" : ".SteamBuyGoodsRequest",
"currencyCode" : "",
"orderId" : "",
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SteamBuyGoodsRequest()
.SetCurrencyCode(currencyCode)
.SetOrderId(orderId)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSteamBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setOrderId(orderId)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSteamBuyGoodsRequest* request = [[GSSteamBuyGoodsRequest alloc] init];
[request setCurrencyCode:currencyCode;
[request setOrderId:orderId;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SteamBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
SteamBuyGoodsRequest request(gsInstance);
request.SetCurrencyCode(currencyCode)
request.SetOrderId(orderId)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.Send(SteamBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SteamBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSteamBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setOrderId(orderId)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.SteamBuyGoodsRequest();
request.currencyCode = ...;
request.orderId = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createSteamBuyGoodsRequest();
request.setCurrencyCode(...);
request.setOrderId(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes a 'orderid’ from a Steam.
The GameSparks platform will validate the 'orderid’ with Steam and process the response. The 'orderid’ from the response will be recorded and the request will be rejected, if the 'orderid’ has previously been processed, this prevents replay attacks.
Once verified, the players account will be credited with the Virtual Good, or Virtual Currency the purchase contains. The virtual good will be looked up by matching the 'itemid’ in the response with the 'Steam Product ID’ configured against the virtual good.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
orderId | Yes | string | Unique 64-bit ID for order |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
verificationError | 1 | No matching virtual good can be found |
verificationError | 2 | The Steam servers failed to verify the order_id |
verificationError | 3 | There was an error connecting to the Steam server |
verificationError | 4 | The order_id has been processed before |
WindowsBuyGoodsRequest
{
"@class" : ".WindowsBuyGoodsRequest",
"currencyCode" : "",
"platform" : "",
"receipt" : "",
"subUnitPrice" : { },
"uniqueTransactionByPlayer" : false
}
{
"@class" : ".BuyVirtualGoodResponse",
"boughtItems" : [ {
"quantity" : 0,
"shortCode" : ""
} ],
"currenciesAdded" : { },
"currency1Added" : 0,
"currency2Added" : 0,
"currency3Added" : 0,
"currency4Added" : 0,
"currency5Added" : 0,
"currency6Added" : 0,
"currencyConsumed" : 0,
"currencyShortCode" : "",
"currencyType" : 0,
"invalidItems" : [ "" ],
"scriptData" : { },
"transactionIds" : [ "" ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new WindowsBuyGoodsRequest()
.SetCurrencyCode(currencyCode)
.SetPlatform(platform)
.SetReceipt(receipt)
.SetSubUnitPrice(subUnitPrice)
.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.Send((response) => {
GSEnumerable<var> boughtItems = response.BoughtItems;
GSData currenciesAdded = response.CurrenciesAdded;
long? currency1Added = response.Currency1Added;
long? currency2Added = response.Currency2Added;
long? currency3Added = response.Currency3Added;
long? currency4Added = response.Currency4Added;
long? currency5Added = response.Currency5Added;
long? currency6Added = response.Currency6Added;
long? currencyConsumed = response.CurrencyConsumed;
string currencyShortCode = response.CurrencyShortCode;
int? currencyType = response.CurrencyType;
IList<string> invalidItems = response.InvalidItems;
GSData scriptData = response.ScriptData;
IList<string> transactionIds = response.TransactionIds;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createWindowsBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setPlatform(platform)
.setReceipt(receipt)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(function(response:com.gamesparks.api.responses.BuyVirtualGoodResponse):void {
var boughtItems:Vector.<Boughtitem> = response.getBoughtItems();
var currenciesAdded:Object = response.getCurrenciesAdded();
var currency1Added:Number = response.getCurrency1Added();
var currency2Added:Number = response.getCurrency2Added();
var currency3Added:Number = response.getCurrency3Added();
var currency4Added:Number = response.getCurrency4Added();
var currency5Added:Number = response.getCurrency5Added();
var currency6Added:Number = response.getCurrency6Added();
var currencyConsumed:Number = response.getCurrencyConsumed();
var currencyShortCode:String = response.getCurrencyShortCode();
var currencyType:Number = response.getCurrencyType();
var invalidItems:Vector.<String> = response.getInvalidItems();
var scriptData:ScriptData = response.getScriptData();
var transactionIds:Vector.<String> = response.getTransactionIds();
});
#import "GS.h"
#import "GSAPI.h"
...
GSWindowsBuyGoodsRequest* request = [[GSWindowsBuyGoodsRequest alloc] init];
[request setCurrencyCode:currencyCode;
[request setPlatform:platform;
[request setReceipt:receipt;
[request setSubUnitPrice:subUnitPrice;
[request setUniqueTransactionByPlayer:uniqueTransactionByPlayer;
[request setCallback:^ (GSBuyVirtualGoodResponse* response) {
NSArray* boughtItems = [response getBoughtItems];
NSDictionary* currenciesAdded = [response getCurrenciesAdded];
NSNumber* currency1Added = [response getCurrency1Added];
NSNumber* currency2Added = [response getCurrency2Added];
NSNumber* currency3Added = [response getCurrency3Added];
NSNumber* currency4Added = [response getCurrency4Added];
NSNumber* currency5Added = [response getCurrency5Added];
NSNumber* currency6Added = [response getCurrency6Added];
NSNumber* currencyConsumed = [response getCurrencyConsumed];
NSString* currencyShortCode = [response getCurrencyShortCode];
NSNumber* currencyType = [response getCurrencyType];
NSArray* invalidItems = [response getInvalidItems];
NSDictionary* scriptData = [response getScriptData];
NSArray* transactionIds = [response getTransactionIds];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void WindowsBuyGoodsRequest_Response(GS& gsInstance, const BuyVirtualGoodResponse& response) {
gsstl:vector<Types::Boughtitem*> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Optional::t_LongOptional currency1Added = response.getCurrency1Added();
Optional::t_LongOptional currency2Added = response.getCurrency2Added();
Optional::t_LongOptional currency3Added = response.getCurrency3Added();
Optional::t_LongOptional currency4Added = response.getCurrency4Added();
Optional::t_LongOptional currency5Added = response.getCurrency5Added();
Optional::t_LongOptional currency6Added = response.getCurrency6Added();
Optional::t_LongOptional currencyConsumed = response.getCurrencyConsumed();
gsstl::string currencyShortCode = response.getCurrencyShortCode();
Optional::t_LongOptional currencyType = response.getCurrencyType();
gsstl:vector<gsstl::string> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
gsstl:vector<gsstl::string> transactionIds = response.getTransactionIds();
}
......
WindowsBuyGoodsRequest request(gsInstance);
request.SetCurrencyCode(currencyCode)
request.SetPlatform(platform)
request.SetReceipt(receipt)
request.SetSubUnitPrice(subUnitPrice)
request.SetUniqueTransactionByPlayer(uniqueTransactionByPlayer)
request.Send(WindowsBuyGoodsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.WindowsBuyGoodsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.BuyVirtualGoodResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createWindowsBuyGoodsRequest()
.setCurrencyCode(currencyCode)
.setPlatform(platform)
.setReceipt(receipt)
.setSubUnitPrice(subUnitPrice)
.setUniqueTransactionByPlayer(uniqueTransactionByPlayer)
.send(new GSEventListener<BuyVirtualGoodResponse>() {
@Override
public void onEvent(BuyVirtualGoodResponse response) {
List<Boughtitem> boughtItems = response.getBoughtItems();
GSData currenciesAdded = response.getCurrenciesAdded();
Long currency1Added = response.getCurrency1Added();
Long currency2Added = response.getCurrency2Added();
Long currency3Added = response.getCurrency3Added();
Long currency4Added = response.getCurrency4Added();
Long currency5Added = response.getCurrency5Added();
Long currency6Added = response.getCurrency6Added();
Long currencyConsumed = response.getCurrencyConsumed();
String currencyShortCode = response.getCurrencyShortCode();
Integer currencyType = response.getCurrencyType();
List<String> invalidItems = response.getInvalidItems();
GSData scriptData = response.getScriptData();
List<String> transactionIds = response.getTransactionIds();
}
});
var request = new SparkRequests.WindowsBuyGoodsRequest();
request.currencyCode = ...;
request.platform = ...;
request.receipt = ...;
request.subUnitPrice = ...;
request.uniqueTransactionByPlayer = ...;
var response = request.Send();
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
var request = RTSession.newRequest().createWindowsBuyGoodsRequest();
request.setCurrencyCode(...);
request.setPlatform(...);
request.setReceipt(...);
request.setSubUnitPrice(...);
request.setUniqueTransactionByPlayer(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var boughtItems = response.boughtItems;
var currenciesAdded = response.currenciesAdded;
var currency1Added = response.currency1Added;
var currency2Added = response.currency2Added;
var currency3Added = response.currency3Added;
var currency4Added = response.currency4Added;
var currency5Added = response.currency5Added;
var currency6Added = response.currency6Added;
var currencyConsumed = response.currencyConsumed;
var currencyShortCode = response.currencyShortCode;
var currencyType = response.currencyType;
var invalidItems = response.invalidItems;
var scriptData = response.scriptData;
var transactionIds = response.transactionIds;
});
Processes a transaction receipt from a windows store purchase.
The GameSparks platform will validate the receipt using the signature embedded in the xml. The Id in the xml will be recorded and the request will be rejected if the Id has previously been processed, this prevents replay attacks.
Once verified, the players account will be credited with the Virtual Good, or Virtual Currency the purchase contains. The virtual good will be looked up by matching the productId in the xml with the 'WP8 Product ID’ configured against the virtual good.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
currencyCode | No | string | The ISO 4217 currency code representing the real-world currency used for this transaction. |
platform | No | string | Allows you to specify the platform |
receipt | Yes | string | The xml reciept returned from the windows phone 8 store |
subUnitPrice | No | number | The price of this purchase |
uniqueTransactionByPlayer | No | boolean | If set to true, the transactionId from this receipt will not be globally valdidated, this will mean replays between players are possible. |
Response Parameters
A response containing details of the bought items
Parameter | Type | Description |
---|---|---|
boughtItems | Boughtitem[] | A JSON object containing details of the bought items |
currenciesAdded | JSON | An object containing the short code and amount added for each currency |
currency1Added | number | How much currency type 1 was added |
currency2Added | number | How much currency type 2 was added |
currency3Added | number | How much currency type 3 was added |
currency4Added | number | How much currency type 4 was added |
currency5Added | number | How much currency type 5 was added |
currency6Added | number | How much currency type 6 was added |
currencyConsumed | number | For a buy with currency request, how much currency was used |
currencyShortCode | string | For a buy with currency request, the short code of the currency used |
currencyType | number | For a buy with currency request, which currency type was used |
invalidItems | string[] | A list of invalid items for this purchase (if any). This field is populated only for store buys |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
transactionIds | string[] | The list of transactionIds, for this purchase, if they exist. This field is populated only for store buys |
Error Codes
Key | Value | Description |
---|---|---|
verificationError | 1 | No matching virtual good can be found |
verificationError | 2 | The XMLSignature validation failed |
verificationError | 5 | The Id in the receipt xml has previously been processed |
Teams
CreateTeamRequest
{
"@class" : ".CreateTeamRequest",
"teamId" : "",
"teamName" : "",
"teamType" : ""
}
{
"@class" : ".CreateTeamResponse",
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"scriptData" : { },
"teamId" : "",
"teamName" : "",
"teamType" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new CreateTeamRequest()
.SetTeamId(teamId)
.SetTeamName(teamName)
.SetTeamType(teamType)
.Send((response) => {
GSEnumerable<var> members = response.Members;
var owner = response.Owner;
GSData scriptData = response.ScriptData;
string teamId = response.TeamId;
string teamName = response.TeamName;
string teamType = response.TeamType;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createCreateTeamRequest()
.setTeamId(teamId)
.setTeamName(teamName)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.CreateTeamResponse):void {
var members:Vector.<Player> = response.getMembers();
var owner:Player = response.getOwner();
var scriptData:ScriptData = response.getScriptData();
var teamId:String = response.getTeamId();
var teamName:String = response.getTeamName();
var teamType:String = response.getTeamType();
});
#import "GS.h"
#import "GSAPI.h"
...
GSCreateTeamRequest* request = [[GSCreateTeamRequest alloc] init];
[request setTeamId:teamId;
[request setTeamName:teamName;
[request setTeamType:teamType;
[request setCallback:^ (GSCreateTeamResponse* response) {
NSArray* members = [response getMembers];
GSPlayer* owner = [response getOwner];
NSDictionary* scriptData = [response getScriptData];
NSString* teamId = [response getTeamId];
NSString* teamName = [response getTeamName];
NSString* teamType = [response getTeamType];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void CreateTeamRequest_Response(GS& gsInstance, const CreateTeamResponse& response) {
gsstl:vector<Types::Player*> members = response.getMembers();
Types::Player* owner = response.getOwner();
GSData scriptData = response.getScriptData();
gsstl::string teamId = response.getTeamId();
gsstl::string teamName = response.getTeamName();
gsstl::string teamType = response.getTeamType();
}
......
CreateTeamRequest request(gsInstance);
request.SetTeamId(teamId)
request.SetTeamName(teamName)
request.SetTeamType(teamType)
request.Send(CreateTeamRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.CreateTeamRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.CreateTeamResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createCreateTeamRequest()
.setTeamId(teamId)
.setTeamName(teamName)
.setTeamType(teamType)
.send(new GSEventListener<CreateTeamResponse>() {
@Override
public void onEvent(CreateTeamResponse response) {
List<Player> members = response.getMembers();
Player owner = response.getOwner();
GSData scriptData = response.getScriptData();
String teamId = response.getTeamId();
String teamName = response.getTeamName();
String teamType = response.getTeamType();
}
});
var request = new SparkRequests.CreateTeamRequest();
request.teamId = ...;
request.teamName = ...;
request.teamType = ...;
var response = request.Send();
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
var request = RTSession.newRequest().createCreateTeamRequest();
request.setTeamId(...);
request.setTeamName(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
});
Allows a new team to be created.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
teamId | No | string | An optional teamId to use |
teamName | Yes | string | A display name to use |
teamType | Yes | string | The type of team to be created |
Response Parameters
A response containing the details of the team that was created
Parameter | Type | Description |
---|---|---|
members | Player[] | The team members |
owner | Player | A summary of the owner |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teamId | string | The Id of the team |
teamName | string | The team name |
teamType | string | The team type |
Error Codes
Key | Value | Description |
---|---|---|
teamType | INVALID | The team type short code supplied does not exist |
teamType | MAX_OWNED_REACHED | The current player has reached the ownership limit of the supplied teamType |
teamType | MAX_TEAMS_REACHED | The current player has reached the membership limit of the supplied teamType |
teamId | NOT_UNIQUE | The teamId supplied already exists |
DropTeamRequest
{
"@class" : ".DropTeamRequest",
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".DropTeamResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new DropTeamRequest()
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createDropTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.DropTeamResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSDropTeamRequest* request = [[GSDropTeamRequest alloc] init];
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSDropTeamResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void DropTeamRequest_Response(GS& gsInstance, const DropTeamResponse& response) {
GSData scriptData = response.getScriptData();
}
......
DropTeamRequest request(gsInstance);
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(DropTeamRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.DropTeamRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.DropTeamResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createDropTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<DropTeamResponse>() {
@Override
public void onEvent(DropTeamResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.DropTeamRequest();
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createDropTeamRequest();
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Allows a player to drop a team.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a drop team request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
teamId|teamType | REQUIRED | Both teamId and teamType have not been provided |
team | INVALID | The teamId or the teamType do not match an existing team |
team | NOT_MEMBER | The current player is not a member of the team they are requesting to leave |
team | NOT_ONWER | The user is not the owner of the team |
teamType | CANNOT_DROP_MANDATORY_TEAM | The team has an ownership of 1 (Mandatory) so cannot be dropped |
teamType&&ownerId | NOT_UNIQUE | The ownerId / teamType combination has multiple teams related to it |
GetMyTeamsRequest
{
"@class" : ".GetMyTeamsRequest",
"ownedOnly" : false,
"teamTypes" : [ "" ]
}
{
"@class" : ".GetMyTeamsResponse",
"scriptData" : { },
"teams" : [ {
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"teamId" : "",
"teamName" : "",
"teamType" : ""
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetMyTeamsRequest()
.SetOwnedOnly(ownedOnly)
.SetTeamTypes(teamTypes)
.Send((response) => {
GSData scriptData = response.ScriptData;
GSEnumerable<var> teams = response.Teams;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetMyTeamsRequest()
.setOwnedOnly(ownedOnly)
.setTeamTypes(teamTypes)
.send(function(response:com.gamesparks.api.responses.GetMyTeamsResponse):void {
var scriptData:ScriptData = response.getScriptData();
var teams:Vector.<Team> = response.getTeams();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetMyTeamsRequest* request = [[GSGetMyTeamsRequest alloc] init];
[request setOwnedOnly:ownedOnly;
[request setTeamTypes:teamTypes;
[request setCallback:^ (GSGetMyTeamsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSArray* teams = [response getTeams];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetMyTeamsRequest_Response(GS& gsInstance, const GetMyTeamsResponse& response) {
GSData scriptData = response.getScriptData();
gsstl:vector<Types::Team*> teams = response.getTeams();
}
......
GetMyTeamsRequest request(gsInstance);
request.SetOwnedOnly(ownedOnly)
request.SetTeamTypes(teamTypes)
request.Send(GetMyTeamsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetMyTeamsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetMyTeamsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetMyTeamsRequest()
.setOwnedOnly(ownedOnly)
.setTeamTypes(teamTypes)
.send(new GSEventListener<GetMyTeamsResponse>() {
@Override
public void onEvent(GetMyTeamsResponse response) {
GSData scriptData = response.getScriptData();
List<Team> teams = response.getTeams();
}
});
var request = new SparkRequests.GetMyTeamsRequest();
request.ownedOnly = ...;
request.teamTypes = ...;
var response = request.Send();
var scriptData = response.scriptData;
var teams = response.teams;
var request = RTSession.newRequest().createGetMyTeamsRequest();
request.setOwnedOnly(...);
request.setTeamTypes(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var teams = response.teams;
});
Get the teams that the player is in. Can be filtered on team type and also on those teams that the player owns.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
ownedOnly | No | boolean | Set to true to only get teams owned by the player |
teamTypes | No | string[] | The type of teams to get |
Response Parameters
A response containing team data for teams that a player belong to
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teams | Team[] | The team data |
GetTeamRequest
{
"@class" : ".GetTeamRequest",
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".GetTeamResponse",
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"scriptData" : { },
"teamId" : "",
"teamName" : "",
"teamType" : "",
"teams" : [ {
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"teamId" : "",
"teamName" : "",
"teamType" : ""
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new GetTeamRequest()
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSEnumerable<var> members = response.Members;
var owner = response.Owner;
GSData scriptData = response.ScriptData;
string teamId = response.TeamId;
string teamName = response.TeamName;
string teamType = response.TeamType;
GSEnumerable<var> teams = response.Teams;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createGetTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.GetTeamResponse):void {
var members:Vector.<Player> = response.getMembers();
var owner:Player = response.getOwner();
var scriptData:ScriptData = response.getScriptData();
var teamId:String = response.getTeamId();
var teamName:String = response.getTeamName();
var teamType:String = response.getTeamType();
var teams:Vector.<Team> = response.getTeams();
});
#import "GS.h"
#import "GSAPI.h"
...
GSGetTeamRequest* request = [[GSGetTeamRequest alloc] init];
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSGetTeamResponse* response) {
NSArray* members = [response getMembers];
GSPlayer* owner = [response getOwner];
NSDictionary* scriptData = [response getScriptData];
NSString* teamId = [response getTeamId];
NSString* teamName = [response getTeamName];
NSString* teamType = [response getTeamType];
NSArray* teams = [response getTeams];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void GetTeamRequest_Response(GS& gsInstance, const GetTeamResponse& response) {
gsstl:vector<Types::Player*> members = response.getMembers();
Types::Player* owner = response.getOwner();
GSData scriptData = response.getScriptData();
gsstl::string teamId = response.getTeamId();
gsstl::string teamName = response.getTeamName();
gsstl::string teamType = response.getTeamType();
gsstl:vector<Types::Team*> teams = response.getTeams();
}
......
GetTeamRequest request(gsInstance);
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(GetTeamRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetTeamRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetTeamResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createGetTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<GetTeamResponse>() {
@Override
public void onEvent(GetTeamResponse response) {
List<Player> members = response.getMembers();
Player owner = response.getOwner();
GSData scriptData = response.getScriptData();
String teamId = response.getTeamId();
String teamName = response.getTeamName();
String teamType = response.getTeamType();
List<Team> teams = response.getTeams();
}
});
var request = new SparkRequests.GetTeamRequest();
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
var teams = response.teams;
var request = RTSession.newRequest().createGetTeamRequest();
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
var teams = response.teams;
});
Allows the details of a team to be retrieved.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response containing the details of the requested teams
Parameter | Type | Description |
---|---|---|
members | Player[] | The team members |
owner | Player | A summary of the owner |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teamId | string | The Id of the team |
teamName | string | The team name |
teamType | string | The team type |
teams | Team[] | A JSON array of teams. |
Error Codes
Key | Value | Description |
---|---|---|
teamId|teamType | REQUIRED | Both teamId and teamType have not been provided |
team | INVALID | The teamId or the teamType do not match an existing team |
teamType&&ownerId | NOT_UNIQUE | The ownerId / teamType combination has multiple teams related to it |
JoinTeamRequest
{
"@class" : ".JoinTeamRequest",
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".JoinTeamResponse",
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"scriptData" : { },
"teamId" : "",
"teamName" : "",
"teamType" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new JoinTeamRequest()
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSEnumerable<var> members = response.Members;
var owner = response.Owner;
GSData scriptData = response.ScriptData;
string teamId = response.TeamId;
string teamName = response.TeamName;
string teamType = response.TeamType;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createJoinTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.JoinTeamResponse):void {
var members:Vector.<Player> = response.getMembers();
var owner:Player = response.getOwner();
var scriptData:ScriptData = response.getScriptData();
var teamId:String = response.getTeamId();
var teamName:String = response.getTeamName();
var teamType:String = response.getTeamType();
});
#import "GS.h"
#import "GSAPI.h"
...
GSJoinTeamRequest* request = [[GSJoinTeamRequest alloc] init];
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSJoinTeamResponse* response) {
NSArray* members = [response getMembers];
GSPlayer* owner = [response getOwner];
NSDictionary* scriptData = [response getScriptData];
NSString* teamId = [response getTeamId];
NSString* teamName = [response getTeamName];
NSString* teamType = [response getTeamType];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void JoinTeamRequest_Response(GS& gsInstance, const JoinTeamResponse& response) {
gsstl:vector<Types::Player*> members = response.getMembers();
Types::Player* owner = response.getOwner();
GSData scriptData = response.getScriptData();
gsstl::string teamId = response.getTeamId();
gsstl::string teamName = response.getTeamName();
gsstl::string teamType = response.getTeamType();
}
......
JoinTeamRequest request(gsInstance);
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(JoinTeamRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.JoinTeamRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.JoinTeamResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createJoinTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<JoinTeamResponse>() {
@Override
public void onEvent(JoinTeamResponse response) {
List<Player> members = response.getMembers();
Player owner = response.getOwner();
GSData scriptData = response.getScriptData();
String teamId = response.getTeamId();
String teamName = response.getTeamName();
String teamType = response.getTeamType();
}
});
var request = new SparkRequests.JoinTeamRequest();
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
var request = RTSession.newRequest().createJoinTeamRequest();
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
});
Allows a player to join a team or a team to be retrieved.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a player joining a team or a request for team data
Parameter | Type | Description |
---|---|---|
members | Player[] | The team members |
owner | Player | A summary of the owner |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teamId | string | The Id of the team |
teamName | string | The team name |
teamType | string | The team type |
Error Codes
Key | Value | Description |
---|---|---|
teamId|teamType | REQUIRED | Both teamId and teamType have not been provided |
team | INVALID | The teamId or the teamType do not match an existing team |
members | ALREADY_JOINED | The current player is already a mamber of the specified team |
members | MAX_MEMBERS_REACHED | The team already has the maximum number of members in it |
teamType | MAX_MEMBERSHIP_REACHED | The current player has already reached the membership limit of this team type |
teamType | NOT_SINGULAR_USE_TEAMID | A player can own more than one of the specified teamType, therefore joining by ownerId and teamType is not sufficient to uniquely identify the team to join. Specify the team by teamId instead. |
teamType | INVALID | The specified team type is invalid. |
teamType&&ownerId | NOT_UNIQUE | The ownerId / teamType combination has multiple teams related to it |
LeaveTeamRequest
{
"@class" : ".LeaveTeamRequest",
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".LeaveTeamResponse",
"members" : [ {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
} ],
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"scriptData" : { },
"teamId" : "",
"teamName" : "",
"teamType" : ""
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new LeaveTeamRequest()
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSEnumerable<var> members = response.Members;
var owner = response.Owner;
GSData scriptData = response.ScriptData;
string teamId = response.TeamId;
string teamName = response.TeamName;
string teamType = response.TeamType;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createLeaveTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.LeaveTeamResponse):void {
var members:Vector.<Player> = response.getMembers();
var owner:Player = response.getOwner();
var scriptData:ScriptData = response.getScriptData();
var teamId:String = response.getTeamId();
var teamName:String = response.getTeamName();
var teamType:String = response.getTeamType();
});
#import "GS.h"
#import "GSAPI.h"
...
GSLeaveTeamRequest* request = [[GSLeaveTeamRequest alloc] init];
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSLeaveTeamResponse* response) {
NSArray* members = [response getMembers];
GSPlayer* owner = [response getOwner];
NSDictionary* scriptData = [response getScriptData];
NSString* teamId = [response getTeamId];
NSString* teamName = [response getTeamName];
NSString* teamType = [response getTeamType];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void LeaveTeamRequest_Response(GS& gsInstance, const LeaveTeamResponse& response) {
gsstl:vector<Types::Player*> members = response.getMembers();
Types::Player* owner = response.getOwner();
GSData scriptData = response.getScriptData();
gsstl::string teamId = response.getTeamId();
gsstl::string teamName = response.getTeamName();
gsstl::string teamType = response.getTeamType();
}
......
LeaveTeamRequest request(gsInstance);
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(LeaveTeamRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LeaveTeamRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LeaveTeamResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createLeaveTeamRequest()
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<LeaveTeamResponse>() {
@Override
public void onEvent(LeaveTeamResponse response) {
List<Player> members = response.getMembers();
Player owner = response.getOwner();
GSData scriptData = response.getScriptData();
String teamId = response.getTeamId();
String teamName = response.getTeamName();
String teamType = response.getTeamType();
}
});
var request = new SparkRequests.LeaveTeamRequest();
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
var request = RTSession.newRequest().createLeaveTeamRequest();
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var members = response.members;
var owner = response.owner;
var scriptData = response.scriptData;
var teamId = response.teamId;
var teamName = response.teamName;
var teamType = response.teamType;
});
Allows a player to leave a team.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a player leaving a team
Parameter | Type | Description |
---|---|---|
members | Player[] | The team members |
owner | Player | A summary of the owner |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teamId | string | The Id of the team |
teamName | string | The team name |
teamType | string | The team type |
Error Codes
Key | Value | Description |
---|---|---|
teamId|teamType | REQUIRED | Both teamId and teamType have not been provided |
team | INVALID | The teamId or the teamType do not match an existing team |
team | CANNOT_LEAVE_OR_JOIN_OWNED_MANDATORY_TEAM | The current player is trying to leave a mandatory team they own. |
team | NOT_MEMBER | The current player is not a mamber of the team they are requesting to leave |
teamType&&ownerId | NOT_UNIQUE | The ownerId / teamType combination has multiple teams related to it |
ListTeamChatRequest
{
"@class" : ".ListTeamChatRequest",
"entryCount" : 0,
"offset" : 0,
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".ListTeamChatResponse",
"messages" : [ {
"@class" : ".ChatMessage",
"fromId" : "",
"id" : "",
"message" : "",
"when" : "2018-07-11T14:02Z",
"who" : ""
} ],
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListTeamChatRequest()
.SetEntryCount(entryCount)
.SetOffset(offset)
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSEnumerable<var> messages = response.Messages;
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListTeamChatRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.ListTeamChatResponse):void {
var messages:Vector.<ChatMessage> = response.getMessages();
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListTeamChatRequest* request = [[GSListTeamChatRequest alloc] init];
[request setEntryCount:entryCount;
[request setOffset:offset;
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSListTeamChatResponse* response) {
NSArray* messages = [response getMessages];
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListTeamChatRequest_Response(GS& gsInstance, const ListTeamChatResponse& response) {
gsstl:vector<Types::ChatMessage*> messages = response.getMessages();
GSData scriptData = response.getScriptData();
}
......
ListTeamChatRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetOffset(offset)
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(ListTeamChatRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListTeamChatRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListTeamChatResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListTeamChatRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<ListTeamChatResponse>() {
@Override
public void onEvent(ListTeamChatResponse response) {
List<ChatMessage> messages = response.getMessages();
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.ListTeamChatRequest();
request.entryCount = ...;
request.offset = ...;
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var messages = response.messages;
var scriptData = response.scriptData;
var request = RTSession.newRequest().createListTeamChatRequest();
request.setEntryCount(...);
request.setOffset(...);
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var messages = response.messages;
var scriptData = response.scriptData;
});
Get a list of the messages sent to the team (by players using SendTeamChatMessageRequest).
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of messages to return (default=50) |
offset | No | number | The offset (nth message) to start from (default=0) |
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a list team messages request.
Parameter | Type | Description |
---|---|---|
messages | ChatMessage[] | The collection of team chat messages |
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
ListTeamsRequest
{
"@class" : ".ListTeamsRequest",
"entryCount" : 0,
"offset" : 0,
"teamNameFilter" : "",
"teamTypeFilter" : ""
}
{
"@class" : ".ListTeamsResponse",
"scriptData" : { },
"teams" : [ {
"owner" : {
"achievements" : [ "" ],
"displayName" : "",
"externalIds" : { },
"id" : "",
"online" : false,
"scriptData" : { },
"virtualGoods" : [ "" ]
},
"teamId" : "",
"teamName" : "",
"teamType" : ""
} ]
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new ListTeamsRequest()
.SetEntryCount(entryCount)
.SetOffset(offset)
.SetTeamNameFilter(teamNameFilter)
.SetTeamTypeFilter(teamTypeFilter)
.Send((response) => {
GSData scriptData = response.ScriptData;
GSEnumerable<var> teams = response.Teams;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createListTeamsRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setTeamNameFilter(teamNameFilter)
.setTeamTypeFilter(teamTypeFilter)
.send(function(response:com.gamesparks.api.responses.ListTeamsResponse):void {
var scriptData:ScriptData = response.getScriptData();
var teams:Vector.<Team> = response.getTeams();
});
#import "GS.h"
#import "GSAPI.h"
...
GSListTeamsRequest* request = [[GSListTeamsRequest alloc] init];
[request setEntryCount:entryCount;
[request setOffset:offset;
[request setTeamNameFilter:teamNameFilter;
[request setTeamTypeFilter:teamTypeFilter;
[request setCallback:^ (GSListTeamsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSArray* teams = [response getTeams];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void ListTeamsRequest_Response(GS& gsInstance, const ListTeamsResponse& response) {
GSData scriptData = response.getScriptData();
gsstl:vector<Types::Team*> teams = response.getTeams();
}
......
ListTeamsRequest request(gsInstance);
request.SetEntryCount(entryCount)
request.SetOffset(offset)
request.SetTeamNameFilter(teamNameFilter)
request.SetTeamTypeFilter(teamTypeFilter)
request.Send(ListTeamsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.ListTeamsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.ListTeamsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createListTeamsRequest()
.setEntryCount(entryCount)
.setOffset(offset)
.setTeamNameFilter(teamNameFilter)
.setTeamTypeFilter(teamTypeFilter)
.send(new GSEventListener<ListTeamsResponse>() {
@Override
public void onEvent(ListTeamsResponse response) {
GSData scriptData = response.getScriptData();
List<Team> teams = response.getTeams();
}
});
var request = new SparkRequests.ListTeamsRequest();
request.entryCount = ...;
request.offset = ...;
request.teamNameFilter = ...;
request.teamTypeFilter = ...;
var response = request.Send();
var scriptData = response.scriptData;
var teams = response.teams;
var request = RTSession.newRequest().createListTeamsRequest();
request.setEntryCount(...);
request.setOffset(...);
request.setTeamNameFilter(...);
request.setTeamTypeFilter(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
var teams = response.teams;
});
Returns a list of teams. Can be filtered on team name or team type.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entryCount | No | number | The number of teams to return in a page (default=50) |
offset | No | number | The offset (page number) to start from (default=0) |
teamNameFilter | No | string | An optional filter to return teams with a matching name |
teamTypeFilter | No | string | An optional filter to return teams of a particular type |
Response Parameters
A response containing the list of teams for a game.
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
teams | Team[] | A list of JSON objects containing team information |
SendTeamChatMessageRequest
{
"@class" : ".SendTeamChatMessageRequest",
"message" : "",
"ownerId" : "",
"teamId" : "",
"teamType" : ""
}
{
"@class" : ".SendTeamChatMessageResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SendTeamChatMessageRequest()
.SetMessage(message)
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSendTeamChatMessageRequest()
.setMessage(message)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.SendTeamChatMessageResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSSendTeamChatMessageRequest* request = [[GSSendTeamChatMessageRequest alloc] init];
[request setMessage:message;
[request setOwnerId:ownerId;
[request setTeamId:teamId;
[request setTeamType:teamType;
[request setCallback:^ (GSSendTeamChatMessageResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SendTeamChatMessageRequest_Response(GS& gsInstance, const SendTeamChatMessageResponse& response) {
GSData scriptData = response.getScriptData();
}
......
SendTeamChatMessageRequest request(gsInstance);
request.SetMessage(message)
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(SendTeamChatMessageRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SendTeamChatMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SendTeamChatMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSendTeamChatMessageRequest()
.setMessage(message)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<SendTeamChatMessageResponse>() {
@Override
public void onEvent(SendTeamChatMessageResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.SendTeamChatMessageRequest();
request.message = ...;
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createSendTeamChatMessageRequest();
request.setMessage(...);
request.setOwnerId(...);
request.setTeamId(...);
request.setTeamType(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Send a message to all the players who are member of the given team
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
message | No | string | The message to send |
ownerId | No | string | The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId | No | string | The teamId to find (may be null if teamType supplied) |
teamType | No | string | The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a send team message request.
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Error Codes
Key | Value | Description |
---|---|---|
team | INVALID | No team exists for the given details |
team | NOT_A_MEMBER | The current player is not a member of the team they are trying to message |
Analytics
AnalyticsRequest
{
"@class" : ".AnalyticsRequest",
"data" : { },
"end" : false,
"key" : "",
"start" : false
}
{
"@class" : ".AnalyticsResponse",
"scriptData" : { }
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new AnalyticsRequest()
.SetData(data)
.SetEnd(end)
.SetKey(key)
.SetStart(start)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createAnalyticsRequest()
.setData(data)
.setEnd(end)
.setKey(key)
.setStart(start)
.send(function(response:com.gamesparks.api.responses.AnalyticsResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
#import "GS.h"
#import "GSAPI.h"
...
GSAnalyticsRequest* request = [[GSAnalyticsRequest alloc] init];
[request setData:data;
[request setEnd:end;
[request setKey:key;
[request setStart:start;
[request setCallback:^ (GSAnalyticsResponse* response) {
NSDictionary* scriptData = [response getScriptData];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void AnalyticsRequest_Response(GS& gsInstance, const AnalyticsResponse& response) {
GSData scriptData = response.getScriptData();
}
......
AnalyticsRequest request(gsInstance);
request.SetData(data)
request.SetEnd(end)
request.SetKey(key)
request.SetStart(start)
request.Send(AnalyticsRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AnalyticsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AnalyticsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createAnalyticsRequest()
.setData(data)
.setEnd(end)
.setKey(key)
.setStart(start)
.send(new GSEventListener<AnalyticsResponse>() {
@Override
public void onEvent(AnalyticsResponse response) {
GSData scriptData = response.getScriptData();
}
});
var request = new SparkRequests.AnalyticsRequest();
request.data = ...;
request.end = ...;
request.key = ...;
request.start = ...;
var response = request.Send();
var scriptData = response.scriptData;
var request = RTSession.newRequest().createAnalyticsRequest();
request.setData(...);
request.setEnd(...);
request.setKey(...);
request.setStart(...);
//Important in RT scripts to manually set the playerId of the request before sending it
//If you don't do this your request will most likely fail with "NOTAUTHORIZED"
request.setPlayerId(...);
request.send(function(response){
var scriptData = response.scriptData;
});
Records some custom analytical data.
Simple analytics, where you just need to track the number of times something happened, just take a key parameter. We’ll record the players id against the data to allow you to report on averages per user
Timed analytics allow you to send start and end timer requests, and with this data GameSparks can track the length of time something takes.
If an end request is sent without a matching start timer the request will fail silently and your analytics data might not contain what you expect.
If both start and end are supplied, the request will be treated as a start timer.
An additional data payload can be attached to the event for advanced reporting. This data can be a string, number or JSON object.
If a second start timer is created using a key that has already had a start timer created without an end, the previous one will be marked as abandoned.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
data | No | JSON | Custom data payload |
end | No | boolean | Use the value true to indicate it’s an end timer |
key | No | string | The key you want to track this analysis with. |
start | No | boolean | Use the value true to indicate it’s a start timer |
Response Parameters
A response to an analytics request
Parameter | Type | Description |
---|---|---|
scriptData | ScriptData | A JSON Map of any data added either to the Request or the Response by your Cloud Code |
EndSessionRequest
{
"@class" : ".EndSessionRequest"
}
{
"@class" : ".EndSessionResponse",
"scriptData" : { },
"sessionDuration" : 0
}
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new EndSessionRequest()
.Send((response) => {
GSData scriptData = response.ScriptData;
long? sessionDuration = response.SessionDuration;
});
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createEndSessionRequest()
.send(function(response:com.gamesparks.api.responses.EndSessionResponse):void {
var scriptData:ScriptData = response.getScriptData();
var sessionDuration:Number = response.getSessionDuration();
});
#import "GS.h"
#import "GSAPI.h"
...
GSEndSessionRequest* request = [[GSEndSessionRequest alloc] init];
[request setCallback:^ (GSEndSessionResponse* response) {
NSDictionary* scriptData = [response getScriptData];
NSNumber* sessionDuration = [response getSessionDuration];
}];
[gs send:request];
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void EndSessionRequest_Response(GS& gsInstance, const EndSessionResponse& response) {
GSData scriptData = response.getScriptData();
Optional::t_LongOptional sessionDuration = response.getSessionDuration();
}
......
EndSessionRequest request(gsInstance);
request.Send(EndSessionRequest_Response);
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.EndSessionRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.EndSessionResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.G