Skip to content

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.
if (await FRVR.notifications.canScheduleMessages()) {
  showReminderToggle();
}

Consent‑gated; many channels require an explicit opt‑in before you can schedule:

await FRVR.notifications.subscribeScheduleMessages();
await FRVR.notifications.scheduleMessage({
  delayInSeconds: 24 * 3600,          // 1 day
  imageUrl:       '/push/daily.png',
  message:        "Don't forget your daily reward!",
  playerId:       FRVR.profile.id(),
  buttons: [
    { type: 'postback', title: 'Play now', payload: JSON.stringify({ deepLink: 'daily' }) },
  ],
});

The buttons[].payload shows up in entry point data when the player arrives through the notification.

Useful for short‑term reminders — e.g. “your energy is full in 30 minutes”:

FRVR.notifications.scheduleLocalNotification(
  'energy_full',                       // code (used to cancel/replace)
  'Energy full!',                      // title
  'Come back and play a few rounds',   // body
  30 * 60,                             // seconds
);

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:

if (FRVR.notifications.supportsLocalNotifications()) {
  setUpReminders();
}

It says nothing about permission. canScheduleMessages() still decides whether a notification will actually be shown.

await FRVR.notifications.unscheduleLocalNotification('energy_full');   // one, by code
await FRVR.notifications.cancelAllLocalNotifications();                // every pending one

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.

MethodPurpose
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.

Notifications: availability + subscribe

loading SDK…