I'm trying to play back PubNub messages in real time as suggested by their Replay functionality, however the only examples I can find online just relate to obtaining a static history of messages over a certain timeframe.
Does anyone know of an online tutorial actually dealing with the Replay API request (rather than History API) or can give some sample code here (Swift if possible)?
The replay feature was only available in the PubNub Node/JavaScript SDK and has been deprecated (it will not be part of the v4 SDKs) because it is not in demand. You can replicate this feature on your end if you require it. Most likely you would want to do this from your server and not your client app but you can do this from your client, too.
Using the history API (Swift SDK for your client implementation), you will retrieve as many of the messages as needed paging through storage since history
only returns 100 messages per call (new features coming in the future to simplify iterative storage paging).
Here is a high level design, from your server, to implement your own replay
feature:
history
, publish it then sleep for the amount of time of the difference between the message timetoken just published and the timetoken of the next message to be published.