Devices/Notifications

Notifications

Reach a player wherever they are, or a device for whoever opens it next.

Devices pages

Notify a player

server.lua
exports.evolent_devices:notify(source, 'hello', {
    id = 'orders',                       -- optional: the same id replaces the older one
    title = '3 orders wait',
    body = 'The first came in 2 minutes ago.',
    action = 'Open',                     -- optional button
    intent = { view = 'orders' },        -- optional, reaches os.onIntent when the button opens your app
})

A notification reaches the player wherever they are, once per notice:

  • Inside the OS of a laptop, a computer or the tablet they hold: the notification centre and a banner of the OS.
  • At no device: a card in a corner of the game screen with your app icon and name, the title and the body. If they carry a tablet item and are not holding it, a short signal and a small "Open your tablet" card instead.
  • On their own laptops and computers in the world: "N new notifications" on the idle screen and a short blink of the screen light. Players nearby see the count only, never the text.
  • Kept on the server for the character until they dismiss it in a notification centre or it is older than Config.notifications.keepDays (at most keep of them). It comes with the next device or tablet they open, after the password if the device has one, and as cards when they join next if they never saw it.

The same id from your app replaces the older one, so a counter like "3 orders wait" can be sent again. Without an id every call is a new notification. The action button opens your app with intent (or { notice = id }) when the app is on that device.

notify allows 5 a second for each app and player, and answers false, 'not_ready' when the character is not loaded.

Options

OptionDescription
popup = falseNo card in the game and no banner in the OS; it goes into the notification centre and the counts only. Use it when your script already shows its own message for the same event.
sound = falseNo sound with the card or the banner.

Notify a device

notifyDevice(deviceId, appId, notice) addresses a laptop or computer instead of a player, for example a desk device of a business: its idle screen counts it, its light blinks, and whoever opens it next sees it in the OS (only after the password if it has one). While someone uses it, it goes into that OS at once. Nobody gets a card in the game.

server.lua
exports.evolent_devices:notifyDevice(12, 'hello', { title = 'New order', body = 'Sultan RS, red' })

Anyone who may open the device sees these notices, so keep private details out of them. Only the owner of the device, the players allowed to manage it and admins clear them; everyone else clears only their own.

It answers false, 'unknown_device' or 'notice_wrong_kind' for a tablet or terminal, and allows 5 a second for each app and device.

Server settings

Admins choose in Settings, Notifications which of the cards, the tablet signal, the screen count and the blink run on the server. Players turn the cards and their sound off for themselves in the Settings app. See Configuration.

The notices hook

The notices hook of your app definition is separate: what it returns shows in the notification centre when the OS opens, and is not kept, counted or shown as a card.