Android Question FCM store messages and show in customlistview

Discussion in 'Android Questions' started by gregorio_adrian_gimenez, Jun 25, 2019.

  1. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed User

    How's everybody?

    I'm finishing a job with FCM
    My question is, can you help me with an example of how to save the messages once received to show them in a Customlistview, whenever you need it.
    What happens now is that when I left and re-entered I lost the messages.

  2. KMatle

    KMatle Expert Licensed User

    Send data messages (search for fcm & data). Then you can decide what to do with these messages.
  3. DonManfred

    DonManfred Expert Licensed User

    What is stopping you from saving the incoming message (topic and body) into a sqlite database?

    You can then use the SQLite-Table to query the Niotifications and show them in a CLV...
    Last edited: Jun 25, 2019
  4. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed User

    Thank you very much for the suggestions.
    I will try with SQLite How
    I would like to have the knowledge that you have
    I hope to make it regards
  5. wes58

    wes58 Active Member Licensed User

    It also depends what you want to do with those messages. Are you going to search for a particular message, or just display all messages received.
    If you are not going to do any sorting, searching for messages then you can simply do something like this.
    Sub Process_Globals
    Type FCMMsg( topic As String, body As String)
    Dim msgList As List
    End Sub

    Sub newFcmMsg(topic As String, body As String)
    Dim newMsg As FCMMsg
        newMsg.body = body
        newMsg.topic = topic
    If Not(msgList.IsInitialized) Then     'you can initialize the list somewhere else
    End If
    End Sub

    Sub readMsg(index as Int)
    Dim msg As FCMMsg
        msg = msgList.Get(index)
    Dim topic as String = msg.topic
    Dim body as String = msg.body
    End Sub
    You don't need any database for this.
    When you get a new message call sub newFcmMsg to add it to the list. You can delete messages from the list. You can save the list to the file and access it any time.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice