FRVR.notifications 在同一个命名空间下处理两件不同的事:
预定的远程消息 —— 由服务器在未来某个时间向这个玩家投递推送(Facebook 上是聊天机器人消息)。
本地通知 —— 应用在后台时,设备在 N 秒后弹一条通知。
if ( await FRVR . notifications . canScheduleMessages ()) {
showReminderToggle ();
}
需要用户同意 —— 很多渠道要求玩家显式 opt-in 之后才能预约:
await FRVR . notifications . subscribeScheduleMessages ();
await FRVR . notifications . scheduleMessage ({
delayInSeconds : 24 * 3600 , // 1 天
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' }) },
],
});
当玩家通过这条通知进入游戏时,buttons[].payload 会出现在 入口 数据里。
适合短时提醒,例如「30 分钟后你的体力满了」:
FRVR . notifications . scheduleLocalNotification (
'energy_full' , // code(用于取消 / 替换)
'Energy full!' , // 标题
'Come back and play a few rounds' , // 正文
30 * 60 , // 秒
);
通知:可用性 + 订阅 loading SDK…
canScheduleMessages() subscribeScheduleMessages() scheduleLocalNotification(…2s…)