gpt4 book ai didi

c# - 使用 Azure 移动服务向非事件用户发送通知。在哪里保存 "lastLoginDate"并对其进行过滤?

转载 作者:行者123 更新时间:2023-11-29 02:15:31 24 4
gpt4 key购买 nike

我一直使用 Parse 来管理我的后端,但由于与 ASP.NET 和 Xamarin 的更好集成而切换到 Azure。在 Parse 中,我创建了一个 PFInstallation 对象,并在发送推送通知之前关联了我需要过滤的任何属性。

在 Azure 移动服务中,我使用以下代码(在 Xamarin iOS 中)注册设备:

public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
try {
var languageCode = NSLocale.PreferredLanguages [0];
ServiceClient.GetPush ().RegisterNativeAsync (deviceToken, new []{ languageCode }).ContinueWith ((t) => {
Console.WriteLine ("Device registration successful!");
});
} catch (Exception e) {
Console.WriteLine ("Could not register device for push notifications: {0}", e.Message);
}
}

我希望有一种方法可以提醒不活跃的用户他们应该再次玩游戏。在 Parse 中,我只是将“lastLoginDate”属性关联到 PFInstallation 对象。我如何使用 Azure 移动服务实现同样的目标?到目前为止,我只能根据用户的设备语言进行过滤(因为我将其保存为标签),但不能根据“lastLoginDate”进行过滤。

PS:在我的后端我想要这样的代码

var users = registrations.Where(u => u.LastLoginDate <= testDate);
SendNotificationToUsers(users);

更新

我阅读了this page您可以使用标签表达式来过滤注册,但在文章中没有指定是否可以使用涉及日期比较的 bool 表达式。有什么帮助吗?

谢谢。

最佳答案

一种方法是让设备在用户每次打开应用程序时注册一个带有当前日期的标签。所以今天我使用这个应用程序,我为标签“last-use-2015-03-02”注册了我的 token 。明天如果我再次使用该应用程序,我将使用标签“last-use-2015-03-03”重新注册,替换 2015-03-02 的设备注册。

然后每天都有一个调度程序向标签发送一周前的消息(例如)。因此,一周后的 3 月 9 日,我可以向所有带有“last-use-2015-03-02”标签的设备发送通知,提醒他们回来。

关于c# - 使用 Azure 移动服务向非事件用户发送通知。在哪里保存 "lastLoginDate"并对其进行过滤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28793035/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com