【发布时间】:2019-12-06 10:43:41
【问题描述】:
是否可以通过本地推送通知触发通知服务扩展?
我的代码sn-p
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
let content = UNMutableNotificationContent()
// Adding title,subtitle,body & badge
content.title = "title"
content.body = "body"
content.sound = UNNotificationSound.default
let aps = ["mutable-content": 1]
let dict = ["aps": aps, "some-key": "some-value"] as [AnyHashable : Any]
content.userInfo = dict
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10, repeats: false)
let request = UNNotificationRequest(identifier: "SimplifiedIOSNotification", content: content as UNNotificationContent, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
【问题讨论】:
-
您是否对此进行了测试以查看是否可行,或者您只是先在这里询问?
-
是的,测试了这个以及远程推送,它只适用于远程推送。
标签: ios swift push-notification extension-methods local