Manage system inbox notifications
Overview
AccelByte Gaming Services (AGS) Chat includes a system inbox notifications feature that enables you to send persistent system notifications to players' inboxes. Examples of system inbox notifications you can send include in-game news, in-game mail, gifts, redemption codes, penalty notifications, player report notifications, maintenance schedules, current events, and more. You can also delete or unsend any notifications from a player's inbox, if necessary.
This article provides information on how to manage and integrate system inbox notifications.
Prerequisites
Administrators must have the following permissions to manage system inbox notifications:
Permissions | Action | Usage |
---|---|---|
ADMIN:NAMESPACE:{namespace}:CHAT:INBOX | CREATE , READ , UPDATE , DELETE | To create, query, edit and remove notifications. |
ADMIN:NAMESPACE:{namespace}:CHAT:INBOX | CREATE , READ , UPDATE , DELETE | To create system message. |
Access the system messages page
To access the management and configuration options outlined in the following sections, log in to your AGS Admin Portal and go to your game namespace dashboard. Then, go to Social > Chat > System Messages.
Manage system inbox notifications
The following sections detail the management of system inbox notifications.
Create, save, and send a notification
To create and send a new system inbox notification, follow these steps:
On the System Messages page, click the + Create new.
Fill out the Create New Message page with the content, recipient, and notification details of your message.
Click Save as Draft to send the message later, or click Send to send the message right away.
Unsend a notification
On the System Messages page, find the sent notification you want to unsend listed under the System Messages List section.
Next to the sent notification, click the ellipsis menu next to it under the Action column. Then, click Unsend.
On the confirmation box, type
UNSEND
and click Unsend to confirm.
View, edit, and send draft notifications
On the System Messages page, find the draft notification you want to view, edit, or send listed under the System Messages List section.
Next to the draft notification, click the View option next to it under the Action column.
Review the information and make any desired changes.
Click Save as Draft to update the message without sending, or click Send to send the message right away.
Integrate system inbox notification into the game client
The example below shows you how to integrate system inbox notification into the game client:
- Unreal Engine
- Unity
// Create API client, login, and connect to AGS Chat
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient(TEXT("0"));
ApiClient->User.LoginWithUsername(TEXT("user+a@example.com"), TEXT("Password321"),
FVoidHandler::CreateLambda([]()
{
UE_LOG(LogTemp, Log, TEXT("Login User A successful"));
}),
FErrorHandler::CreateLambda([](int Code, FString const& Message)
{
UE_LOG(LogTemp, Log, TEXT("Login User A failed"));
}));
ApiClient->Chat.Connect();
// Set delegate for incoming system message notification
ApiClient->Chat.SetSystemMessageNotifDelegate(
Api::Chat::FSystemMessageNotif::CreateLambda([](const FAccelByteModelsChatSystemMessageNotif&
Notif)
{
UE_LOG(LogTemp, Log, TEXT("Got System Message: %s %s %s"), *Notif.MessageId, *Notif.Message,
*Notif.Category);
}));
// Query system message
{
FAccelByteModelsQuerySystemMessagesResponse Result;
Chat::FQuerySystemMessageResponse OnSuccess = Chat::FQuerySystemMessageResponse::CreateLambda(
[&Result](const FAccelByteModelsQuerySystemMessagesResponse& Response)
{
Result = Response;
});
FErrorHandler OnError = FErrorHandler::CreateLambda([](int32 Code, const FString& Message)
{
UE_LOG(LogTemp, Error, TEXT("Failed query chat system message %d, %s"), Code, *Message);
});
ApiClient->Chat.QuerySystemMessage(OnSuccess, OnError);
}
// Update system message (mark read/unread or keep messages)
{
FAccelByteModelsActionUpdateSystemMessage Action;
Action.ID = TEXT("message-id");
Action.Read = EAccelByteOptionalBool::NO; // mark message as unread
Action.Keep = EAccelByteOptionalBool::YES; // mark message to keep in inbox
Chat::FUpdateSystemMessagesResponse OnSuccess =
Chat::FUpdateSystemMessagesResponse::CreateLambda(
[](const FAccelByteModelsUpdateSystemMessagesResponse& Response)
{
UE_LOG(LogTemp, Log, TEXT("Update system message success"));
});
FErrorHandler OnError = FErrorHandler::CreateLambda([](int32 Code, const FString& Message)
{
UE_LOG(LogTemp, Error, TEXT("Failed update chat system message %d, %s"), Code, *Message);
});
ApiClient->Chat.UpdateSystemMessages({Action}, OnSuccess, OnError);
}
// Delete system message
{
Chat::FDeleteSystemMessagesResponse OnSuccess =
Chat::FDeleteSystemMessagesResponse::CreateLambda(
[](const FAccelByteModelsDeleteSystemMessagesResponse& Response)
{
UE_LOG(LogTemp, Log, TEXT("Delete system message success"));
});
FErrorHandler OnError = FErrorHandler::CreateLambda([](int32 Code, const FString& Message)
{
UE_LOG(LogTemp, Error, TEXT("Failed delete chat system message %d, %s"), Code, *Message);
});
ApiClient->Chat.DeleteSystemMessages({TEXT("message-id")}, OnSuccess, OnError);
}
// Get system message stats
{
FAccelByteGetSystemMessageStatsResponse Result;
Chat::FGetSystemMessageStatsResponse OnSuccess =
Chat::FGetSystemMessageStatsResponse::CreateLambda(
[&Result](const FAccelByteGetSystemMessageStatsResponse& Response)
{
Result = Response;
});
FErrorHandler OnError = FErrorHandler::CreateLambda([](int32 Code, const FString& Message)
{
UE_LOG(LogAccelByteChatTest, Error, TEXT("Failed get system message stats %d,
%s"), Code, *Message);
});
ApiClient->Chat.GetSystemMessageStats(OnSuccess, OnError);
}
// Create API client, login, and connect to Chat
var apiClient = AccelByteSDK.GetClientRegistry().GetApi();
Result<TokenData, OAuthError> loginResult;
apiClient.GetUser().LoginWithUsernameV3(userEmailAddress, userPassword, (Result<TokenData, OAuthError> result) =>
{
loginResult = result;
if (result.IsError)
{
// Handle login error
return;
}
apiClient.GetChat().Connect();
});
// Set delegate for incoming system message notification
apiClient.GetChat().NewSystemMessage += notif =>
{
Debug.Log($"Got new system message: {notif.MessageId} {notif.Message} {notif.Category}");
};
// Query system message
var request = new QuerySystemMessageRequest
{
UnreadOnly = true,
Offset = 0,
Limit = 5
};
QuerySystemMessagesResponse querySystemMessagesResponse = null;
apiClient.GetChat().QuerySystemMessage(result =>
{
querySystemMessagesResponse = result.Value;
}, request);
// Update system message (mark read/unread or keep messages)
UpdateSystemMessagesResponse updateSystemMessagesResponse = null;
var action = new ActionUpdateSystemMessage
{
Id = "messageId",
Read = OptionalBoolean.No,
Keep = OptionalBoolean.Yes
};
apiClient.GetChat().UpdateSystemMessages(new HashSet<ActionUpdateSystemMessage> { action }, result =>
{
updateSystemMessagesResponse = result.Value;
});
// Delete system message
DeleteSystemMessagesResponse response = null;
var messageIds = new HashSet<string>
{
"messageId1",
"messageId2"
};
apiClient.GetChat().DeleteSystemMessages(messageIds, result =>
{
response = result.Value;
});
// Get system message stats
GetSystemMessageStatsResponse systemMessageStats = null;
apiClient.GetChat().GetSystemMessagesStats(delegate (Result<GetSystemMessageStatsResponse> result)
{
systemMessageStats = result.Value;
Debug.Log($"Stats: {systemMessageStats.Unread} {systemMessageStats.OldestUnread}");
});