Basic Usage
This guide will walk you through the basic setup and usage of the notifier SDK.
Sending a Notification
To send a player a notification, use notifier.notify(). This is the core function of the SDK.
notifier.notify(player, {
asset_id = "12341234-1234-1234-1234-123412341234",
})You can include several optional parameters to customize the notification.
Note
The asset_id corresponds to a notification created in the Creator Dashboard. You can learn more about creating notifications in the Notification Strings guide.
Here is an example with all possible parameters:
notifier.notify(player, {
asset_id = "842f00f6-758b-e948-95a9-745431d90a97",
time = DateTime.fromUnixTimestampMillis(DateTime.now().UnixTimestampMillis + (24 * 60 * 60 * 1000)), -- 24 hours from now
priority = 5,
string_parameters = { points = "55555" },
launch_data = "red",
analytics_data = "daily",
})Opt-In
notifier.canOptIn(player) checks if a player is eligible to opt-into receiving notifications based on a few different factors.
If they are eligible, you can use notifier.optIn(player) to prompt them to enable notifications.
if notifier.canOptIn(player) == true then
notifier.optIn(player)
endImportant
You can only call optIn for a player only once every 30 days.
Player Joined Event
When a player joins the game, use notifier.joined(player). This is used to clear old notifications.
notifier.joined(player)