Notifications
FRVR.notifications handles two distinct things under one namespace:
- Scheduled remote messages — the server schedules a push (or chatbot message on Facebook) to be delivered to this player at a future time.
- Local notifications — the device fires a notification N seconds from now while the app is backgrounded.
Check availability
Section titled “Check availability”Subscribe the player
Section titled “Subscribe the player”Consent‑gated; many channels require an explicit opt‑in before you can schedule:
Schedule a remote message
Section titled “Schedule a remote message”The buttons[].payload shows up in entry point data when the player arrives through the notification.
Schedule a local notification
Section titled “Schedule a local notification”Useful for short‑term reminders — e.g. “your energy is full in 30 minutes”:
Scheduling again with the same code replaces the earlier notification.
Not every channel has local notifications. supportsLocalNotifications() answers synchronously and never prompts the player, so you can check it before loading anything a notification needs:
It says nothing about permission. canScheduleMessages() still decides whether a notification will actually be shown.
Cancel local notifications
Section titled “Cancel local notifications”Both are safe to call anywhere. They do nothing if the code was never scheduled, has already fired, or the channel has no local notifications.
API summary
Section titled “API summary”| Method | Purpose |
|---|---|
canScheduleMessages() | Can this player receive notifications? |
subscribeScheduleMessages() | Ask the player to opt in. Resolves true if they accept. |
scheduleMessage(params) | Schedule a remote message. |
supportsLocalNotifications() | Does the channel have local notifications? Synchronous. |
scheduleLocalNotification(code, title, text, seconds) | Schedule a local notification. |
unscheduleLocalNotification(code) | Cancel one pending local notification. |
cancelAllLocalNotifications() | Cancel every pending local notification. |