API Reference of GS2-AdReward SDK for Game Engine
Model
EzPoint
Ad viewing points
Records the total number of points earned by the player by viewing ads. Each time a player views an ad, they earn points, which can be used to exchange rewards or purchase in-game benefits.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
point | long | ✓ | 0 | ~ 9223372036854775805 | Number of points held |
Methods
getPoint
Get Point
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzPoint | Point |
Implementation Example
var domain = gs2.AdReward.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Point(
);
var item = await domain.ModelAsync();
var domain = gs2.AdReward.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Point(
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->AdReward->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Point(
);
const auto Future = Domain->Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.AdReward.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Point(
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.AdReward.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Point(
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->AdReward->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Point(
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::AdReward::Model::FPoint> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
Event Handler
OnChangePointNotification
Notification when point changes due to ad viewing
Name | Type | Description |
---|---|---|
namespaceName | string | Namespace name |
userId | string | User Id |
Implementation Example
gs2.AdReward.OnChangePointNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var userId = notification.UserId;
};
gs2.AdReward.OnChangePointNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var userId = notification.UserId;
};
Gs2->AdReward->OnChangePointNotification().AddLambda([](const auto Notification)
{
const auto NamespaceName = Notification->NamespaceNameValue;
const auto UserId = Notification->UserIdValue;
});