timeToLive
field which indicates the time in seconds up to which a presence is valid. After the time has elapsed, the user presence automatically shifts to the next presence in line (if any).Presence
object, to begin with. Therefore, let’s build one:PresenceBuilder
to build a cascading presence in a fluent manner. In a nutshell, the user’s presence begins with Online
then shifts to Away
after 15 seconds and so on.Presence
object, you can choose either the manual approach or the automatic one for updating. It’s recommended that you use the automatic approach as it’s less management work for you.startAutoUpdateCurrentUserPresence()
method on the Users
object:Online
. Once the user exits your app, it stops polling and as a result, the presence starts expiring to the next status as discussed earlier.Note: Here, the second argument value is the polling interval (in secs). Therefore, this example sets polling every 5 seconds.
setCurrentUserPresence()
method on the Users
object. Something like this:Note: This is a one-shot update call. If you don’t make this call periodically, the current user’s presence will shift to the next expiring presence after thetimeToLive
has elapsed, even if your app is open.
getUserPresence()
method on the Users
object.SentTime
timeline event to every message you sent.mitter.mtet.SentTime
- The time at which the message was sentmitter.mtet.ReceivedTime
- The time at which the message was received by the servermitter.mtet.DeliveredTime
- The time at which the message was delivered to the usermitter.mtet.ReadTime
- The time at which the message was read by the usermitter.mtet.DeliveredTime
and mitter.mtet.ReadTime
events where you don’t have to set these types explicitly. You’ll see how.addReadTimelineEvent()
method on the Messaging
object. Here’s a quick demo:onValueUpdatedCallback
, if you want to be notified after the operation has succeeded.addTimelineEvent()
method to add a timeline event to your messages. This method accepts a TimelineEvent
object which you need to construct on your own, fully customised to your needs.TimelineEvent
object with some required parameters, as follows:type
is the type of the event that you’re sending, eventTimeMs
is the timestamp you want to associate with the event and the subject
is the user with whom this event should be associated.subject
would the receiving user who has read the message.addTimelineEvent()
method and supplying the TimelineEvent
object that you created in the previous step. This is how the code looks:addReadTimelineEvent()
method with the exception that it accepts a TimelineEvent
object without assuming anything on it’s own.