【发布时间】:2020-03-06 10:36:36
【问题描述】:
当应用程序处于后台并将其发送到persistentContainer时,我正在尝试获取通知详细信息,例如消息或图像或其他内容。使用Message方法时,我收到Use of unresolved identifier。我该如何解决这个问题? ?
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let text=userInfo["text"] as! String
let image=userInfo["image"] as! String
guard let url=URL(string: image) else
{
completionHandler(.noData)
return
}
let persistentContainer=NSPersistentContainer(name: "PushMe")
let context=persistentContainer.viewContext
context.perform
{
do
{
let message=Message(context:context)
}
catch{
}
}
}
请帮助我。在此先感谢。
【问题讨论】:
-
什么是消息?它是如何声明的?
-
这是一个内置方法
-
消息必须是类型、结构或类,而不是方法。您希望它在哪里是内置的、swift 或 UIKit 或...?
标签: ios swift xcode message identifier