See UNNotificationTrigger for more information. 实例,直接获取相应的值即可: // identifier: 唯一标识符 // content:要展示的消息内容,详见UNNotificationContent // trigger:触发的方式,详见 UNNotificationTrigger public convenience init(identifier: String, content: UNNotificationContent, trigger: UNNotificationTrigger @NSCopying open var trigger: UNNotificationTrigger? @available(iOS 12.0, *) open var summaryArgumentCount: Int UNNotificationTrigger 推送的触发器 是一个抽象类,他有四个子类
UNNotificationTrigger:通知的触发器,由其子类具体定义。 UNNotificationAttachment:通知附件类,为通知内容添加媒体附件。 UNPushNotificationTrigger:远程通知的触发器,UNNotificationTrigger子类。 UNTimeInervalNotificationTrigger:计时通知的触发器,UNNotificationTrigger子类。 UNCalendarNotificationTrigger:周期通知的触发器,UNNotificationTrigger子类。 UNLocationNotificationTrigger:地域通知的触发器,UNNotificationTrigger子类。
的代理回调事件中,告知App接收到一条通知,包含一个发起通知的请求UNNotificationRequest UNNotificationRequest包含通知内容UNNotificationContent和触发器UNNotificationTrigger [UIApplication sharedApplication].applicationIconBadgeNumber = 0; NSLog(@"%@",@"处理通知"); } 触发器 UNNotificationTrigger
} } 4、本地推送 在iOS10中,UserNotifications框架为我们提供了UNMutableNotificationContent对象描述消息推送的标题、内容、提示音、角表等内容,UNNotificationTrigger UNNotificationTrigger有四个子类,分别是UNTimeIntervalNotificationTrigger用于通过时间间隔控制消息推送,UNCalendarNotificationTrigger
首先设置信息内容 UNMutableNotificationContent 和触发机制 UNNotificationTrigger ;然后用这两个值来创建 UNNotificationRequest;最后将
,@"key2":@"value2"}; 3、创建完整的本地推送请求Demo //定时推送 + (void)createLocalizedUserNotification{ // 设置触发条件 UNNotificationTrigger