[iOS SDK] "send message" method should have a callback

21 views
Skip to first unread message

biga...@gmail.com

unread,
Oct 12, 2015, 8:44:23 AM10/12/15
to Realtime Framework
Hello,

In iOS SDK, the "send message" method should have a callback parameter, called when the message has been posted to server.

Long story short, the callback is required to send message when user "minimizes" the application.

Detailed use case:
Assume that some application sends a message when user puts it to background.
On iOS, when the application is moved to the background state, it is completely paused, i.e. all threads are suspended and no code is executed until the application is resumed (moved to the foreground state).
To allow for some finalizing, iOS provides the "extended" state, when the application isn't suspended in background for some period of time (documentation). When finished, the application *must* call the endBackgroundTask: method to let the system know that it is finished and can be suspended. So if the application sends a message in background, it has to know when the message is completely posted to the server to call endBackgroundTask.

That's what I want:
[ortcClient send:channel message:message callback:^(BOOL success) {
NSLog(@"Done!");
}];

With best regards,
Andrey Smachev

João Parreira

unread,
Oct 12, 2015, 1:45:12 PM10/12/15
to realtime-...@googlegroups.com
Hi Andrey,
We agree and we are working on a new server version of the Realtime Messaging service where the send method has a success/error callback.
However we don't have an ETA at the moment.

Meanwhile you can use the send route of the REST API. It will give a 201 status code if the message was successfully published and 401 otherwise (note, this doesn't mean all subscribers got the message, only that the Realtime server received your send request and will in a best-effort way try to deliver all the required copies to the channel subscribers).

To make your life easier we have written a simple example and pushed to GitHub:
https://github.com/JoaoCaixinha/RealtimeMessaging-iOS-sendREST

The method that sends the message using an async POST can be found here:
https://github.com/JoaoCaixinha/RealtimeMessaging-iOS-sendREST/blob/master/Ortc-iOS-Send-Rest/ViewController.m#L71-L114

Hope this helps.



--
You received this message because you are subscribed to the Google Groups "Realtime Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realtime-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrey Smachev

unread,
Oct 13, 2015, 3:39:19 PM10/13/15
to João Parreira, realtime-...@googlegroups.com
Thank you very much, João, for your comprehensive answer!


On Mon, 12 Oct 2015 18:45:04 +0100 (WEST)
João Parreira <jpar...@ibt.pt> wrote:

> Hi Andrey,
> We agree and we are working on a new server version of the Realtime
> Messaging service where the send method has a success/error callback.
> However we don't have an ETA at the moment.
>
> Meanwhile you can use the send route of the REST API. It will give a
> 201 status code if the message was successfully published and 401
> otherwise (note, this doesn't mean all subscribers got the message,
> only that the Realtime server received your send request and will in
> a best-effort way try to deliver all the required copies to the
> channel subscribers).
>
> To make your life easier we have written a simple example and pushed
> to GitHub:
> https://github.com/JoaoCaixinha/RealtimeMessaging-iOS-sendREST
>
> The method that sends the message using an async POST can be found
> here:
> https://github.com/JoaoCaixinha/RealtimeMessaging-iOS-sendREST/blob/master/Ortc-iOS-Send-Rest/ViewController.m#L71-L114
>
> Hope this helps.
>
> ----- Original Message -----
>
> | From: biga...@gmail.com
> | To: "Realtime Framework" <realtime-...@googlegroups.com>
> | Sent: Monday, October 12, 2015 1:44:22 PM
> | Subject: [Realtime Framework] [iOS SDK] "send message" method should
> | have a callback
>
> | Hello,
>
> | In iOS SDK, the "send message" method should have a callback
> | parameter, called when the message has been posted to server.
>
> | Long story short, the callback is required to send message when user
> | "minimizes" the application.
>
> | Detailed use case:
> | Assume that some application sends a message when user puts it to
> | background.
>
> | On iOS, when the application is moved to the background state, it is
> | completely paused, i.e. all threads are suspended and no code is
> | executed until the application is resumed (moved to the foreground
> | state).
>
> | To allow for some finalizing, iOS provides the "extended" state,
> when | the application isn't suspended in background for some period
> of | time ( documentation ). When finished, t he application *must*
Reply all
Reply to author
Forward
0 new messages