zoukankan      html  css  js  c++  java
  • 本地通知

    import UserNotifications

    func regisNot(){

            

            if #available(iOS 10.0, *) {

                UNUserNotificationCenter.current().requestAuthorization(options: [.alert]) { (success, error) in

                    if success {

                        print("success")

                    } else {

                        print("error")

                    }

                }

            } else {

                // Fallback on earlier versions

            }

            

            

            // 1

            if #available(iOS 10.0, *) {

                let content = UNMutableNotificationContent()

                content.title = "Notification Tutorial"

                content.subtitle = "from ioscreator.com"

                content.body = " Notification triggered"

                

                // 2

                let imageName = "Icon123"

                guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return }

                

                let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none)

                

                content.attachments = [attachment]

                

                // 3

                let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10, repeats: false)

                let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger)

                

                // 4

                UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)

            } else {

                // Fallback on earlier versions

            }

            

            

            

            

            

            

        }

        

    群号:186052819
  • 相关阅读:
    小程序全局生命周期( 仅供了解 )
    iview表格render小案例2
    iview中表格根据条件渲染
    如何实现页面同时在移动端和pc端的兼容问题
    小程序页面中的生命周期( 仅供了解 )
    弹性盒基本属性
    elementUI实现分页效果+模糊搜索效果
    事件流 ---- 事件冒泡与事件捕获
    React生命周期
    数据库索引数据结构btree,b-tree和b+tree树
  • 原文地址:https://www.cnblogs.com/zuidap/p/6274522.html
Copyright © 2011-2022 走看看