FRVRSDK.Notifications 调度一条稍后送达的远程推送 / 聊天机器人消息 —— 经典的”明天再来玩”留存提示。Unity 封装包主要面向 Facebook Instant;其它渠道可能 no-op。
FRVRSDK.Notifications.CanScheduleMessages(canSchedule =>
{
if (canSchedule) ShowReminderToggle();
});
玩家必须同意接收来自渠道的消息。一旦 CanScheduleMessages 说 yes,订阅就是免费的:
FRVRSDK.Notifications.SubscribeScheduleMessages(
() => Debug.Log("subscribed"),
err => Debug.LogError(err));
只在 CanScheduleMessages 为 true 时才显示你的 “Remind me tomorrow” 开关;玩家第一次开启时再调用 SubscribeScheduleMessages。
var config = new ScheduleMessageConfig
{
playerId = "5116605215082224",
delayInSeconds = 86400, // 1 天
imageUrl = "https://cdn.mygame.com/push.png",
message = "Your daily reward is ready!",
buttons = new[]
{
new ScheduleMessageButton
{
type = "game_play",
title = "Play!",
payload = "{\"deepLink\":\"daily\"}"
}
}
};
FRVRSDK.Notifications.ScheduleMessage(config,
() => Debug.Log("scheduled"),
err => Debug.LogError(err));
当玩家点开推送时,你的游戏会在入口数据里收到 payload 字符串 —— 在那里把玩家路由到对应界面。
FRVRSDK.Notifications.CanScheduleMessages(canSchedule =>
{
if (!canSchedule) return;
FRVRSDK.Notifications.SubscribeScheduleMessages(() =>
{
var cfg = new ScheduleMessageConfig
{
playerId = currentPlayerId,
delayInSeconds = 86400,
imageUrl = "https://cdn.mygame.com/daily.png",
message = "Your daily reward is ready!",
buttons = new[] { new ScheduleMessageButton { type = "game_play", title = "Play!", payload = "" } }
};
FRVRSDK.Notifications.ScheduleMessage(cfg,
() => { /* 已调度 */ },
err => Debug.LogError(err));
}, err => Debug.LogError(err));
});