【发布时间】:2017-12-02 20:44:34
【问题描述】:
我对编程和开发一个应用程序相当陌生,该应用程序会在我的商店开张时通知用户。我正在使用 firebase 来存储数据,我希望使用本地通知而不是推送。
我根据一些在线资源设置了我的应用程序委托以发送通知,但我不确定如何为其调用函数。我在 Xcode 中使用 swift 4。
import Firebase
var refNotificationValue = DatabaseReference!
@IBAction func openButtonClicked(_ sender: UIButton) {
// Alert Controller confirming actions
self.shouldSendNotification()
}
// DidLoad()
refNotificationValue = database.database().reference().child("Notifications").child("enabled") // set to yes
// EndLoad()
func shouldSendNotification () {
refNotificationValue?.observeSingleEvent(of: .value, with: { (snapshot) in
let dict = snapshot.value as! [String: Any]
let status = dict["enabled"] as! String
if status == "yes" {
setToOpen()
sendNotification()
} else {
setToOpen()
}
})
}
func sendNotification() {
????????
}
提前非常感谢!
【问题讨论】:
标签: ios swift firebase notifications local