usermessagemanager - TogetherGames/Public-Corona-Lua GitHub Wiki

UserMessageManager

together.UserMessageManager

Overview

The UserMessageManager class is used to find and fetch messages directly sent to the current session's User account. With this class, a developer will be able to create a message, delete a message, get all messages, and mark a message as read. A Developer can use UserMessages as in-game email.


Members

table UserMessages

Stores all the UserMessages contained in the Manager.


Methods


Add()

Adds a UserMessage to the internally managed list without persistence.

Note
This method is deprecated

Returns void
Syntax
UserMessageManager:Add( userMessage )
Parameters

TogetherUserMessage userMessage

Instance of a UserMessage to add internally

--------------------------------------------------------------------------------

FindByUserMessageID()

Finds the UserMessage with the specified UserMessageID if it exists, otherwise returns nil.

Syntax
UserMessageManager:FindByUserMessageID( userMessageID )
Parameters

number userMessageID

The ID of the UserMessage to find

--------------------------------------------------------------------------------

GetCount()

Gets the number of UserMessages currently managed internally.

Returns number
Syntax
UserMessageManager:GetCount(  )

Get()

Gets the UserMessage at the specified index if it exists, otherwise returns nil.

Syntax
UserMessageManager:Get( index )
Parameters

number index

The index of the UserMessage to find

--------------------------------------------------------------------------------

IndexOf()

Returns the index of the specified UserMessage if it exists, otherwise returns nil.

Returns number
Syntax
UserMessageManager:IndexOf( userMessage )
Parameters

TogetherUserMessage userMessage

Instance of the UserMessage to find the index of

--------------------------------------------------------------------------------

IndexOfByUserMessageID()

Returns the index of the UserMessage with the specified UserMessageID if it exists, otherwise returns -1.

Returns number
Syntax
UserMessageManager:IndexOfByUserMessageID( userMessageID )
Parameters

number userMessageID

The ID of the UserMessage to find the index of

--------------------------------------------------------------------------------

Remove()

Removes a UserMessage from the internally managed list. This does not delete the message from the user's mailbox persistently.

Note
This method is deprecated

Returns void
Syntax
UserMessageManager:Remove( index )
Parameters

number index

The index of the UserMessage to remove internally

--------------------------------------------------------------------------------

GetAll()

Gets all UserMessages assigned to the User. Upon success, this will automatically update the internal mailbox.

Returns void
Syntax
UserMessageManager:GetAll( unreadOnly, startID, count, callbackFunc )
Parameters

boolean unreadOnly

A Boolean indicating whether only unread messages should be retrieved.

[number](#) startID

The ID of the UserMessage to start with when returning UserMessages.

[number](#) count

The max number of UserMessages to return.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

CreateMessage()

Sends a message to a specific User. Upon success, this will automatically update the internal mailbox.

Returns void
Syntax
UserMessageManager:CreateMessage( destinationUserID, title, message, isGameIndependent, messageProperties, callbackFunc )
Parameters

number destinationUserID

The ID of the User to send the UserMessage to.

[string](#) title

The title of the UserMessage.

[string](#) message

The message of the UserMessage.

[boolean](#) isGameIndependent

A boolean indicating whether the generated UserMessage is assigned to the Game being played.

[PropertyCollection](./propertycollection) messageProperties

The properties to assign to the UserMessage. Pass in nil to assign no properties.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

MarkMessageAsRead()

Marks a UserMessage as read. Upon success, this will automatically update the internal mailbox.

Returns void
Syntax
UserMessageManager:MarkMessageAsRead( userMessageID, callbackFunc )
Parameters

number userMessageID

The ID of the UserMessage to mark as read.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

DeleteMessage()

Deletes a UserMessage. Upon success, this will automatically update the internal mailbox.

Returns void
Syntax
UserMessageManager:DeleteMessage( userMessageID, callbackFunc )
Parameters

number userMessageID

The ID of the UserMessage to delete.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------
⚠️ **GitHub.com Fallback** ⚠️