Manage system inbox notifications
Overview
The AccelByte Gaming Services (AGS) System Inbox Notifications feature 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, a gift, a redeem code, penalty notifications, player report notifications, maintenance schedule, current event, and many more.
You can also delete or unsend any notifications from a player's inbox, if necessary.
Prerequisites
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
Log in to the AGS Admin Portal.
Go to the game namespace.
On the sidebar, select Chat, then select System Messages.
Manage system inbox notifications
Create and send a notification
On the System Messages page, click on + Create New button.
Fill in the fields with the required information to create the notification.
Click the Create and Send button to send the message right away.
Create a draft notification
On the System Messages page, click on + Create New button.
Fill in the fields with the required information to create the notification.
Click Save as Draft to save the notification as a draft and send it at a later time.
Unsend a notification
On the System Messages page, find the sent notification you want to unsend.
ヒントYou can set the Status filter to Sent to only display sent notifications in the list.
Click the notification's ellipsis menu, then select Unsend.
Click Confirm, then click the Unsend button.
View, edit, and send draft notifications
On the System Messages page, find the draft notification you want to view or edit.
Click the View button of the notification to open.
Click on the pencil button to start editing.
Click Send Notification to send the notification 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 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
ApiClient user = MultiRegistry.GetApiClient("default");
Result loginResult;
user.GetUser().LoginWithUsernameV3("", "", result =>
{
loginResult = result;
Debug.Log(loginResult.IsError ? "login error" : "login success");
});
user.GetChat().Connect();
// Set delegate for incoming system message notification
user.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;
user.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
};
user.GetChat().UpdateSystemMessages(new HashSet<ActionUpdateSystemMessage>{ action }, result =>
{
updateSystemMessagesResponse = result.Value;
});
// Delete system message
DeleteSystemMessagesResponse response = null;
var messageIds = new HashSet<string>
{
"messageId1",
"messageId2"
};
user.GetChat().DeleteSystemMessages(messageIds, result =>
{
response = result.Value;
});
// Get system message stats
GetSystemMessageStatsResponse systemMessageStats = null;
user.GetChat().GetSystemMessagesStats(delegate(Result<GetSystemMessageStatsResponse> result)
{
systemMessageStats = result.Value;
Debug.Log($"Stats: {systemMessageStats.Unread} {systemMessageStats.OldestUnread}");
});