如何在UserDefault中存储推送通知警报消息? [英] How can I store Push Notification alert message in UserDefault?

查看:186
本文介绍了如何在UserDefault中存储推送通知警报消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个应用程式,我可以收到推送通知,并保存在客户端设备的限制25通知。如果应用程序正在运行并可能无法运行。如何存储PushNotification警报消息?如果app运行那段时间到达通知警报消息存储在UserDefault中,但当应用程序处于后台或非活动状态时,则在UserDefault中不存储通知警报消息。我想知道,我需要使用UserDefault或CoreData在客户端应用程序中存储推送通知消息吗?如果不是,我应该使用什么?我真的需要一个手来接我。

I want to build an app that I can receive push notification and save inside client device for limit 25 Notification. If application running and may not running. How can I stored PushNotification alert message?. If app running that time arrived Notification alert message stored in UserDefault but when app in background or Inactive state that time not stored Notification alert message in UserDefault. I want to know that I need to use UserDefault or CoreData to store the Push Notification message inside client app or not? If it is not, what should I use? I really need a hand to pick me up.

请帮助。感谢。

推荐答案

在我看来,您可以使用 NSUserDefaults 相关信息。在您的情况下推送通知。然而,只是一个想法,你可以简单地附加通知到本地存储或用户设备上的 txt 文件,并删除元素,因为用户访问它。

In my opinion you can use NSUserDefaults to store user related information. Push Notifications in your case. However, just a thought, you can simple append the notifications to local storage or a txt file on user device and remove the element as user accesses it.

但这只会在用户使用应用程序时工作。如果你想要使这项工作即使当应用程序不工作,你需要做一个后端,并将这些数据存储在某种云数据库。当应用程序再次打开时,您可以从数据中提取记录并再次推送到 NSUserDefaults 或本地 txt 文件。

But this will only work when user is using the app. In case you want to make this work even when the app is not working, you need to make a backend and store these data in some kind of cloud database. You can extract the records from data and push again to NSUserDefaults or local txt file when the app is turned on again.

这篇关于如何在UserDefault中存储推送通知警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆