//
// ViewController.swift
// Dome2test
//
// Created by 郭文亮 on 2018/11/22.
// Copyright © 2018年 finalliang. All rights reserved.
//
import UIKit
//用户通知类库
import UserNotifications
//对于函数 类和协议。可以使用@available声明这些类型的生命周期,依赖于特定的平台货或者操作系统版本
@available(iOS 10.0,*)
//使用当前的的视图控制器类 尊魂用户通知中心协议。 用于处理接受的通知 以及通知相关错左操作
class ViewController: UIViewController ,UNUserNotificationCenterDelegate{
override func viewDidLoad() {
super.viewDidLoad()
//创建一个本地通知对象
let localNotification = UILocalNotification()
//创建一个基于当前时间的日期对象
let now = Date()
//设置在当前时间的五秒后 触发本地通知
localNotification.fireDate = now.addingTimeInterval(5)
//然后设置本地通知的重复次数
localNotification.repeatInterval = NSCalendar.Unit.init(rawValue: 0)
//设置本地通知的时区为默认时区
localNotification.timeZone = .current
//设置本地通知的提醒声音模版
localNotification.soundName = UILo
IOS实用功能-系统本地通知的创建
最新推荐文章于 2020-05-16 22:39:09 发布
//// ViewController.swift// Dome2test//// Created by 郭文亮 on 2018/11/22.// Copyright © 2018年 finalliang. All rights reserved.//import UIKit//用户通知类库import UserNotifications//对于函数 类和协议。可以...
摘要由CSDN通过智能技术生成