ios - 通知到来时没有调用 didReceiveRemoteNotification 方法
问题描述
我不明白为什么我的代码不起作用。
我的代码是:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
print("User Info = ",userInfo)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadChatTableView"), object: nil)
GlobalConstant.notificationDict = userInfo
let notificationDictionary: NSDictionary = GlobalConstant.notificationDict?["aps"] as! NSDictionary
let type: String = Global.getStringValue(notificationDictionary.value(forKey: "type") as AnyObject)
// application.applicationIconBadgeNumber = application.applicationIconBadgeNumber + 1
completionHandler(UIBackgroundFetchResult.noData)
var aps: [AnyHashable: Any] = userInfo["aps"] as! [AnyHashable : Any]
//content.sound = UNNotificationSound.init(named: "tone.mp3")
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil
}
解决方案
推荐阅读
- ruby-on-rails - 如何在不重新加载页面的情况下显示评论?
- python - python - 如果嵌套的json值不存在,如何忽略它的父级?
- javascript - TypeScript 不知道组件从 HOC 获得所需的道具
- hibernate - IDE 没有显示任何错误,但是 Jasper Report 在通过浏览器中的 HTML 表单的过滤属性发送过滤数据时没有弹出
- java - 在java中的arraylist中搜索整数
- javascript - 使用 Python、sqlite3、HTML 和 JavaScript 编写代码动态下拉列表
- javascript - 转换数组对象及其重写的函数
- blueprism - 如何使用来自另一个 Web 应用程序对象的操作
- c# - 使用 HttpClient 将 Windows 身份验证传递给代理
- windows - 我可以删除用户输入的文件夹名称的最后一个 \ 吗?