找回密码
 立即注册
查看: 260|回复: 0

本地通知

[复制链接]
发表于 2022-4-27 09:45 | 显示全部楼层 |阅读模式
(1)导入插件
using Unity.Notifications.iOS;
否则请前往Unity Asset Store下载相关插件
(2)注销所有通知
iOSNotificationCenter.ApplicationBadge = 0;

        iOSNotificationCenter.RemoveAllDeliveredNotifications();

        iOSNotificationCenter.RemoveAllScheduledNotifications();
(3)设置每日10点发送一条通知


先创建一个触发器,如下:
var calendarTrigger = new iOSNotificationCalendarTrigger() { Hour = 10, Minute = 0, Second = 0, Repeats = true };
然后创建通知对象
iOSNotification notification = new iOSNotification(){

            Data = data,

            Title = title, //标题

            Body = msg, //消息内容

            Identifier = "Notification_" + notificationId, //每条通知的id注意做区分

            Badge = notificationId,

            ShowInForeground = true, //应用在前台是否还显示通知

            ForegroundPresentationOption = (PresentationOption.Alert | PresentationOption.Sound | PresentationOption.Badge), //通知紧急程度

            CategoryIdentifier = "category_a",

            ThreadIdentifier = "thread1",

            Trigger = calendarTrigger, //触发器

        };
(4)注册通知
iOSNotificationCenter.ScheduleNotification(notification);
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-22 13:22 , Processed in 0.092225 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表