but why then you call it messages? if i even can’t realise even simple mechanic of messaging (like imessages for example) beatween 2 people. And anyway need to somehow keep all in date base and make code for it. or is there any other ways?
Thanks
oh… i’m not arguing just asking, no more Probably missed something in your example. Look through once more and let you know if will have a questions with more details. Thanks
select your app in console
click the Code Generation icon
select iOS in the menu
click Sample Chat under Messaging > Publish/Subscribe.
That will generate a project with source code for your app which demonstrates basic chat between 2 people.
Chat history can be implemented with custom server-side code. All one needs to do is to add a “beforePublish” or “afterPublish” handler and store the published messages in the Data service.
Yep, but still will have a problem if user gets messages when he not in application. Then i probably need to use some timer to check server is there any new messages, or probably we could realise it on some other way? Could you help us manage this issue?
The best way to preserve messages is by writing custom server-code for the message “publish” event and store incoming messages in our data store. When users come online, your app would first check in the data store (using Data Service API) and then use messaging “subscribe” function to receive messages from the Messaging Service.
Please would you give some code sample that implements message storing in data service?
1- which api should be used to check the new messages in data store?
2- How recipient to receive the stored message by subscribing ?
Am really scratching my head around this . Problem with implementing server-side-code, in Android, is one would need two adapters, one to populate data from the stored record API and another to populate from the messaging API. Which one do u show coz one cannot show both simultaneously ? i stand corrected.
He is trying to say he will need two different sources of data for the chat view. In iOS terms - datasources for ViewController, in Android terms adapters for Activity.
The apparent problem is the synchronization - should the app fetch Messages or BackendlessEntities to fill UITableView (or ListView)?
Perhaps there ought to be yet another object - a ViewModel for the TableViewCell, that will be created with a Message or with Entity.
It really is a strange setup at least from my experience with other messaging systems like socket.io. I’m not sure if there is any performance advantage as we have to save the messages to the database anyway.
Could you give us hint on how to do it in Javascript backend? This is what I have got so far from the generated code:
Backendless.ServerCode.Messaging.beforePublish('*', function(req) {
//add your code here
var chatObject = new ChatMessage( {
text: "", // how do I get it?
userId: "",
conversationId: "",
});
var savedContact = Backendless.Persistence.of( Contact ).save( chatObject );
});