ios - 从消息过滤器扩展发送本地通知
问题描述
我正在实施消息过滤器扩展,但在使用通知时遇到问题。关键是我想为进入垃圾文件夹的每条消息触发通知。我在 MainViewController 中测试了通知的代码,它工作正常。Bellow 是我正在使用的代码,我在 viewDidLoad() 方法中要求用户权限。
函数发送通知(){
print("sendNotification.....")
//creating the notification content
let content = UNMutableNotificationContent()
//adding title, subtitle, body and badge
content.title = "Hey, test notification"
content.subtitle = "iOS Development is good"
content.body = "We are learning about iOS Local Notification"
content.badge = 1
//getting the notification trigger
//it will be called after 5 seconds
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
//getting the notification request
let request = UNNotificationRequest(identifier: "SimplifiedIOSNotification", content: content, trigger: trigger)
UNUserNotificationCenter.current().delegate = self
//adding the notification to notification center
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) }
当消息被过滤为垃圾邮件以通知用户时,有没有办法发送通知?谢谢开发者。
解决方案
推荐阅读
- mysql - 如何在 Laravel 中使用 SELECT 上的计算字段进行子查询?
- python - 从 Excel 导入数据框中的错误行和列
- php - 使用 PHP 从 CURL “-d” 中检索数据
- spring-boot - Kafka 流 - 第一个示例 WordCount 不起作用(计数值错误)
- haskell - fromInteger 应该是环同态吗?
- python - 具有基于键的默认值的 Python dict
- azure-active-directory - 如何将 Azure 应用注册从 DEV 带到 PROD 而无需手动重新创建它们?
- excel - Excel VBA 简单网页抓取,但未使用 CTRL+A 选择表格
- android - 任务':app:kaptDebugKotlin'的java.lang.reflect.InvocationTargetException(无错误消息)
- r - R中的主成分分析图