原文地址:Unity 移動端通知推送功能實現(xiàn) - Warren的文章 - 知乎
https://zhuanlan.zhihu.com/p/222015804
因為項目需求需要增加每天在指定時間推送通知,增加了如下函數(shù)
public static void SendRepeatNotification(string title,string text)
? ? {
? ? ? ? Init();
? ? ? ? DateTime now = DateTime.Now;
? ? ? ? AndroidNotification notification = new AndroidNotification
? ? ? ? {
? ? ? ? ? ? Title = title,
? ? ? ? ? ? Text = text,
? ? ? ? ? ? FireTime = new DateTime(now.Year, now.Month, now.Day, 12, 0, 0).AddDays(1),
? ? ? ? ? ? RepeatInterval = new TimeSpan(1, 0, 0, 0),
? ? ? ? ? ? IntentData = "{\"title\": \"Notification 1\", \"data\": \"200\"}",
? ? ? ? ? ? ShouldAutoCancel = true
? ? ? ? };
? ? ? ? AndroidNotificationCenter.SendNotification(notification, "channel_id");
? ? }