Native storage, local storage or sqlite?


#1

Hi guys. In my ionic 3 android app, i need save the push notifications received for read in the future The notifications contais extra data (data property from the notifications payload). What better method for this?
native storage, local storage or sqlite?
I’m using FCM plugin. The payload like this
{
“to” : “bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1…”,
“priority” : “normal”,
“notification” : {
“body” : “This week’s edition is now available.”,
“title” : “NewsMagazine.com”,
“icon” : “new”
},
“data” : {
“volume” : “3.21.15”,
“contents” : “http://www.news-magazine.com/world-week/21659772
}
}

Thanks for some help


Difference from Storage and Native Storage
#2

You forgot the simplest option: Ionic Storage (with sqlite as datastore if you like).

Native storage will only work on native platforms, so no testing in the browser.
Local storage is highly unreliable when use directly.
SQLite (when used as the interface!) is relational and much too complex.

Ionic Storage is super simple, key-value, reliable and used in so many Ionic apps.


#3

Thanks Sujan!
I did not find the Ionic Storage Plugin in the Ionic documentation. Where can I find it?


#4

Google “Ionic Storage”.
(It’s not a plugin, but more deeply integrated into the Framework)

(You can also just click this link here: https://ionicframework.com/docs/storage/)


#5

Sujan, i have one question: How can I return all records?
Need to return the records and through ngFor show the data in a card.
Can you help me please?


#6

“all records” is not an exact description.

If you add “widgets” to a list called “widgets”, of course you can get this list from Storage and iterate over it. THat is what it is for.


#7

I did not express myself.
In my case, I’ll record push notifications using ionic storage.
The key will be the “id” of the notification and the notification is associated with that key.
Since I have multiple notifications, I need to bring all of them, so I have to iterate through the database and bring all the notifications into a list
Thanks


#8

Then you would save all this in a notifications list or object. Read this object, you have all of them and can then filter or reorder them as you like.

(That is a different way of thinking than with relational databases. As you don’t have “tables”, you have to create something similar by stuffing everything inside an object/list.)


#9

Hello,
I need to store MP3 files locally (10MB-40MB) and looking for the adequate local storage solution. I would like this Wirkung in a PWA, too.
Can anyone recommend me, what I should use?
Regards and thanks


#10

You can use the combo Ionic Native File + Ionic Native File Transfer.

I use this plugins for download photos and videos (Ionic Native File transfer) et read them offline (Ionic Native File).