In-Game Messaging

Introduction

In-Game messages are used in games to inform and reward players. These messages allow you, the developer, to communicate directly with your players. The messages can build excitement for future LiveOps events, enhance player on-boarding, inform players about updates, and help with Customer Support.

Behind the scenes, LionSDK uses the Nakama SDK from Heroic Labs to help schedule and track in-game messages.

Features

  • You can send messages to all users with specific start and expiration times.
  • The messages can contain rewards that the users can claim.
  • Set custom icons to display the rewards.

Requirements

  • In-Game Messaging requires you to have a Nakama instance for your game. Lion Studios has an Enterprise Nakama license from Heroic Labs to cover all our published games. Please contact Support for help setting up your Nakama instance.

Installation

Adding a New Message

  • Go to Lion Portal > LionSDK > In Game Messaging
  • Provide information to the following fields and hit Submit to send a message payload:
    • Environment: The Nakama instance where the message will be added. The client has to connect to the same instance for the message to show up in the game. (modifiable in LionStudios > Settings Manager > Nakama)
      • Production (Lion Core)
      • Staging (Lion Staging)
    • Bundle ID: The game that will be receiving the message.
    • Password: The RPC password for this game. If you need help, contact @lion_support on Slack.
    • Message Title: The title of the message.
    • Message Content: The text content of the message.
    • Start Time: Schedule when the message will start showing up in the users’ mailbox.
    • Expiration Time: Schedule when the message will disappear from the users’ mailbox.
    • Priority: Define the order of the message for the mailbox. Messages with higher priority will be shown on top.
    • Reward Item Name: Optional field to configure a reward to be given with the message. If a value is provided, the client needs to implement that reward’s display and distribution. See Displaying Rewards and Distributing Rewards
    • Reward Amount: Required field if Reward Item Name is provided to define the quantity of rewards for the message.

Untitled

Displaying Messages

  • Add Resources/MessagingCanvas.prefab to your scene. This will be the UI for displaying the messages. You can have your own prefab variant of this with your desired UI changes. An example to do that is shown here Customizing Module UI.
    • Note: Dont’ disable MessageListView Gameobject.
  • Add Prefabs/MessageBoxOpenButton.prefab to your scene. This will be the button to open the messages object you added above.
  • Configure Display Priority on for messages:
    • Go to unity menu tab, then LionStudios → Settings Manager → Messages

Displaying Rewards

You will find Assets/Resources/LionStudios/RewardIcons.asset automatically added to your project. You can configure the display icons of the rewards on this asset. This will map the given reward name to the icon. The reward name is set when adding a new message, see example RPC payload above.

Screenshot 2023-05-15 at 18.11.04.png

Distributing Rewards

Set a callback using MessageManager.SetClaimRewardsCallback method. Your callback should take MessageRewardData[], and return bool. Your callback will automatically be invoked when the claim button is clicked on the message rewards section. Handle distributing the rewards there and return true if the distribution is successful.

void Start()
{
		MessageManager.SetClaimRewardsCallback(ClaimRewards);
}

bool ClaimRewards(MessageRewardData[] rewards)
{
		foreach(MessageRewardData reward in rewards)
		{
				Debug.Log("Reward item: " + reward.rewardItemName + " amount " + reward.amount);
				// Claim the reward
		}
		return true;
}