核心数据和用户默认值不存储数据

问题描述 投票:-2回答:1

关闭我的应用程序时,核心数据和UserDefaults不存储数据。

我在关闭应用程序时会收到通知,因此我将其存储在核心数据中,并且默认情况下会做一些事情。

当应用程序打开时,它存储所有信息,但是只有应用程序关闭,它不起作用,任何想法都可以这样做。

我将数据存储在以下功能中。

  func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
            let response = notification.request.content.userInfo["aps"] as! NSDictionary
             //here i will send response will store to core date
            self.defaults.set("1", forKey: "notifyid")
            completionHandler([.alert, .badge, .sound])
        }
    } 

Core Data和UserDefaults在我的应用程序关闭时不存储数据。当我的应用程序关闭时,我会收到通知,因此我将其存储在核心数据中,并且默认情况下会做一些事情。当...

ios swift core-data default
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.