我从远程通知中获取字符串类型,我想在应用程序关闭或设备解锁时针对每种接收到的类型显示一条消息 这是我的尝试
let dict = userInfo["aps"] as! NSDictionary
let message = dict["alert"]
let type = userInfo[AnyHashable("type")] as! String
print(type)
let notification = UILocalNotification()
if type == "501 " {
notification.alertBody = "Оцените водителя"
notification.alertTitle = "Оцените наш сервис"
notification.fireDate = Date(timeIntervalSinceNow: 1)
UIApplication.shared.presentLocalNotificationNow(notification)
}
print("message")
print(message!)