我正在处理本地通知,但我遇到的问题是当应用程序终止时没有调用 didReceive Response 方法,所以当我点击通知操作时,它只是启动应用程序而没有做任何其他事情。但是当应用程序只是在后台时,一切都像往常一样。我的代码有什么问题吗?
//MyClassNameViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
UNUserNotificationCenter.current().delegate = self
}
func triggerAlarm1() {
// Create an instance of notification center
let center = UNUserNotificationCenter.current()
// Sets the details of the notification
let content = UNMutableNotificationContent()
content.title = "Recorded Today's first alarm."
content.body = "Be completely honest: how is your day so far?"
content.sound = UNNotificationSound.default()
content.categoryIdentifier = "notificationID1"
// Set the notification to trigger everyday
let triggerDaily = Calendar.current.dateComponents([.hour,.minute], from: myTimePicker1.date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDaily, …Run Code Online (Sandbox Code Playgroud) 有没有办法检索子进程中的所有键,将它们放入数组,然后检索键的值并将其放入另一个数组?
源代码:
self.ref?.child("data").child("success").child(userID!).observeSingleEvent(of: .value, with: { (snapshot) in
if snapshot != nil {
// Your answer goes here
}
}
Run Code Online (Sandbox Code Playgroud)