-1

In my App there is PubNub used for Chat function,and for delete chat history,there is Web service,In app chat history clear successfully,but when application in background state and another user send message to me,notification is received and if I open that notification, it redirect to Chat Controller, but my problem is that when chat history clear successfully,still on my chat page all deleted message are present,is there is solution to delete message from pub-nub?

snehal B.
  • 29
  • 6
  • What do you mean you successfully deleted chat history in PubNub? We do not directly support delete of stored messages. Please elaborate - maybe some code? – Craig Conover May 09 '16 at 20:49

1 Answers1

1

PubNub Message Update & Delete Features - NEW

Update Published Messages using the Message Actions feature.

pubnub.addMessageAction(
  {
    channel: 'chats.room123'
    messageTimetoken: '15610547826970040',
    action: {
      type: 'updated',
      value: 'Hello World! (edited)',
    },
  },
  function(status, response) {
  }
);

Delete Messages using the deleteMessages API.

There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Admin Portal. Requires Initialization with the secret key.

pubnub.deleteMessages(
  {
    channels: 'chats.room1',
    start: "15526611838554309",
    end: "15526611838554310",
  },
  function (status, response) {
    console.log(status, response);
  }
);

Soft Delete a Message, using the Message Actions feature.

"action": {
  "type": "deleted",
  "value": "."
}

UPDATE: THIS DESIGN PATTERN IS STILL LEGITIMATE BUT IS OUTDATED. PLEASE REFER TO THE ABOVE FOR BEST PRACTICES.

PubNub Storage/History Update & Delete Design Pattern

Although PubNub's API does not directly support the editing of stored messages, you can use a design pattern authored by one of our very own Solution Architects.

Message Updates and Deletes Design Pattern

Craig Conover
  • 4,710
  • 34
  • 59