How to update a sent message in Quickblox IOS - ios

How do I update a sent QBChatMessage in the server? For e.g. After the message is sent/delivered, how does one update it's text or custom parameters. Also are there parameters that cannot be changed or updated once sent and delivered?
Here's a link to the snippet on Quickblox Android that seems to be doing the same. How is this achieved in IOS?

There is a method in QBRequest:
/**
Update existing chat message - mark it as read.
#param message Сhat message to update.
#param successBlock Block with response instance if request succeded.
#param errorBlock Block with response instance if request failed.
#return An instance of QBRequest for cancel operation mainly.
*/
+ (QBRequest *)updateMessage:(QBChatMessage *)message
successBlock:(nullable void(^)(QBResponse *response))successBlock
errorBlock:(nullable QBRequestErrorBlock)errorBlock;
The usage is the same as in android pretty much. Here you can read which fields you can update: http://quickblox.com/developers/Chat#Fields_to_update_2

Related

Microsoft Azure Service Bus Message completed

In .NET Framework Microsoft.ServiceBus.Messaging had a class used to receive messages from Service Bus, BrokeredMessage. However, in .NET Standard 2.0, in order to receive messages from a Service Bus, class Message is used, from Microsoft.Azure.ServiceBus.Core.
BrokeredMessage has a method, CompleteAsync(), used to complete the receive operation of a message and indicates that the message should be marked as processed and deleted. I can't find a method for the Message class that does the same thing. Do you guys know any solution in order to mark a message as processed and deleted for the Message class?
To complete the message in the Queue using Microsoft.Azure.ServiceBus.Core, there is a method CompleteAsync available in the QueueClient, through which the messages will be received.
The lock token of the message should be passed as the parameter for the CompleteAsync method.
Example: queueClient.CompleteAsync(message.SystemProperties.LockToken)

Not able to process response received from template.convertSendAndReceive()

I am trying to send message and receive response using following code
MessageProperties props =MessagePropertiesBuilder.newInstance().setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
.setMessageId("MSG12345").setHeader("type", "type1").setCorrelationId(UUID.randomUUID().toString().getBytes()).build();
Message message = MessageBuilder.withBody(input.getBytes()).andProperties(props).build();
Message response = (Message) template.convertSendAndReceive("key", message);
But, its is throwing ava.lang.ClassCastException: java.lang.String cannot be cast to org.springframework.amqp.core.Message
May be because, I am sending request using java (spring-amqp) program and the receiver is a python (pika) program.
Recevier is sending me a JSON object dumped in string format but I am not able to handle it.
Your problem that you use RabbitTemplate.convertSendAndReceive():
/**
* Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a
* specific routing key and attempt to receive a response, converting that to a Java object. Implementations will
* normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
*
* #param routingKey the routing key
* #param message a message to send
* #return the response if there is one
* #throws AmqpException if there is a problem
*/
Object convertSendAndReceive(String routingKey, Object message) throws AmqpException;
Even if your payload is Message and we we have:
protected Message convertMessageIfNecessary(final Object object) {
if (object instanceof Message) {
return (Message) object;
}
return getRequiredMessageConverter().toMessage(object, new MessageProperties());
}
It converts a reply into a target object from body:
return this.getRequiredMessageConverter().fromMessage(replyMessage);
and don't return Message as you expected.
So, you really have to cast to String and deal with your JSON already on your own.

How to update Read and Delivery status of sent and received messages using Quickblox IOS?

I have implemented a chat sample app using Quickblox,And I followed SampleChat app provided by Quckblox(Urls provided below). But I want to update Read and Delivery status of each message. How to achieve this?
http://quickblox.com/developers/SimpleSample-chat_users-ios
https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat
In link 1 they have explained some code but I'm unable to implement.
There are docs for read and delivered status in the link you provided.
To make this answer more explicit, there are several ways to mark messages as read and delivered. For delivered marking there is only XMPP way available, use this method from QBChat to do it:
/**
* Send "delivered" status for message.
*
* #param message QBChatMessage message to mark as delivered.
* #param completion Completion block with failure error.
*/
- (void)markAsDelivered:(QB_NONNULL QBChatMessage *)message completion:(QB_NULLABLE QBChatCompletionBlock)completion;
For read marker you can use either REST request using QBRequest method:
/**
Mark messages as read.
#note Updates message "read" status only on server.
#param dialogID dialog ID.
#param messagesIDs Set of chat message IDs to mark as read. If messageIDs is nil then all messages in dialog will be marked as read.
#param successBlock Block with response instance if request succeded.
#param errorBlock Block with response instance if request failed.
#return An instance, which conforms Cancelable protocol. Use this instance to cancel the operation.
*/
+ (QB_NONNULL QBRequest *)markMessagesAsRead:(QB_NONNULL NSSet QB_GENERIC(NSString *) *)messagesIDs
dialogID:(QB_NONNULL NSString *)dialogID
successBlock:(QB_NULLABLE void(^)(QBResponse * QB_NONNULL_S response))successBlock
errorBlock:(QB_NULLABLE QBRequestErrorBlock)errorBlock;
or XMPP method of QBChat:
/**
* Send "read" status for message and update "read" status on a server
*
* #param message QBChatMessage message to mark as read.
* #param completion Completion block with failure error.
*/
- (void)readMessage:(QB_NONNULL QBChatMessage *)message completion:(QB_NULLABLE QBChatCompletionBlock)completion;
Anyway look closer to samples and documentation if you need a "live" example.

How to get the sent emails in ios

I have a requirement that I have to send an email and show them in sent items. Using iOS mail API. I can send the email. But I am not able to retrieve the sent items.
Is there any possible way to store the sent email and show them in sent items with all the details like ( to, message body,...) ?
Is it possible to fetch any information from MFMailComposeViewController in the delegate methods?
­-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:
(MFMailComposeResult)result error:(NSError *)error {
// Any way to fetch sent mail info
}
You can set MFMailComposeViewControllerDelegate in your code. This delegate has a method
- mailComposeController:didFinishWithResult:error:
which sends the results enum through which you can figure out if the mail was sent or not. Then you can save your email message/subject and show the user list of emails they have sent.

Mark all messages read in QuickBlox iOS

I am developing an chat base application with the help of QuickBlox.
There is an Api that returns chat dialogs where the last sent message and unread-messages count comes.
My problem is to mark messages as read. For this i got the working code like
[QBChat markMessagesAsRead:arrMessages dialogID:dialogId delegate:self]; // arrMessages is the array of message ids
It works well but sometime what happens some of message gets skipped and it always comes as unread messages in QBChatDialog
So My question is what should i do to mark all messages of it as read.
Or
How can i get those particular skipped messages that are unread. As it call the api to get messages it give only last one not that particular skipped.
You can mark all messages as read just passing nil as the array parameter
[QBChat markMessagesAsRead:nil dialogID:dialogId delegate:self];
In that case ALL your messages should be marked as read

Resources