跳转到内容

通知(Cocos)

FRVRSDK.instance 让你请求宿主渠道在未来某个时间向玩家投递推送 / 聊天机器人消息 —— 经典的”明天再来”召回提示。Facebook Instant 支持最完善;其他渠道可能直接 no-op。

  1. 调用 canScheduleNotifications() —— 当前渠道是否具备这个能力?
  2. 玩家首次同意时调用 subscribeNotifications()
  3. scheduleNotification(config) 排入一条具体消息。
if (await FRVRSDK.instance.canScheduleNotifications()) {
  showReminderToggle();
}

只在它为 true 时才暴露你的”提醒我”UI —— 否则点了也没用。

await FRVRSDK.instance.subscribeNotifications();

第一次玩家把提醒开关打开时调用。后续重复调用是安全的;一旦订阅,后续都是 no-op。

await FRVRSDK.instance.scheduleNotification({
  playerId:       await FRVRSDK.instance.getPlayerId(),
  delayInSeconds: 24 * 3600,                     // 1 天
  imageUrl:       'https://cdn.mygame.com/daily.png',
  message:        'Come back and play!',
  buttonTitle:    'Play Now',
});

玩家点进来时,游戏启动时会带上对应的入口数据 —— 用 entrypoint 把他们路由到正确的画面。

if (!await FRVRSDK.instance.canScheduleNotifications()) return;

await FRVRSDK.instance.subscribeNotifications();

await FRVRSDK.instance.scheduleNotification({
  playerId:       await FRVRSDK.instance.getPlayerId(),
  delayInSeconds: 86400,
  imageUrl:       'https://cdn.mygame.com/push.png',
  message:        'Your daily reward is ready!',
  buttonTitle:    'Play Now',
});