Usage examples
These are examples of using 'Mailbox'. In the production environment, implement it to fit your app's operating policy and app UI/UX.
To call any mailbox method, you need an active session of a logged-in user. First complete Install the module, initialize, and log in.
- Send reward mail and check the status
- Check received mail and change the mail status
- Delete received mail
- Recall mistakenly sent mail and clean up sent mail
Send reward mail and check the status
Send mail to users who meet specific conditions, such as ranking rewards or attendance rewards, and check the status after sending.
-
The app server or app client checks the reward grant conditions and prepares the mail title, body, sender name, expiration time, recipients, and attached items.
-
Send the mail. Set
RecipientScopetoDirectand put the list of recipientPlayerIdvalues inRecipientPlayerIds. For mail with attached items, put the list of attached items inAttachments. -
Handle the mail sending result. If sending succeeds, save the
MailIdfrom the response data. You useMailIdlater to check the sending status, recall the mail, and clean up the sending history. If you do not receive a success response, handle it according to the response status in Send mail. -
Get sent mail. To check the status of a specific mail item right after sending, call
GetMailAsync()with the savedMailId. To also view the sending history or to find theMailIdagain, useGetSentMailsAsync()to checkMailStatus,ExpiresAt, and the number of recipients.
Check received mail and change the mail status
When the user checks mail that contains attached items on the mailbox screen and opens the mail, reflect the body read status and the attached item claim status separately.
-
The user enters the mailbox screen in the app.
-
Get the received mail list. When you implement the mailbox list screen, call
GetReceivedMailsAsync()from the app client to load the received mail list. On the mail list screen, show a summary of the title, expiration time, and read status. -
When the user selects a specific mail item on the mail list screen, call
GetReceivedMailAsync()to check the mail body, attached items,MailStatus,TextReadAt, andAttachmentReadAttogether. At this time, also passLanguage. -
When the user reads the body of the selected mail, call
MarkMailAsReadAsync()withTarget = Textto reflect the body read status. -
When the user checks the attached items or the app determines that the download is complete, the app client or app server processes the actual attached items. When that determination is complete, the app client calls
MarkMailAsReadAsync()withTarget = AttachmentorAllto reflect the attached item claim status. -
Handle the read result. If you receive a success response, immediately update the mailbox screen state based on
TextReadAtandAttachmentReadAtin the response. If you do not receive a success response, handle it according to the response status in Mark mail as read.
Delete received mail
Clean up mail that the user has already checked or no longer wants to keep from the mailbox list.
-
The user selects the mail to delete on the mailbox list screen.
-
The app client checks the
MailRecipientIdof the mail to delete. If you want to also show whether the attached items have been claimed or whether the mail has expired, check the result ofGetReceivedMailAsync()as needed. -
Handle the deletion result. If you receive a success response, remove the deleted mail from the mailbox list and recalculate the number of remaining mail items. If you do not receive a success response, handle it according to the response status in Delete received mail.
Recall mistakenly sent mail and clean up sent mail
Recall mail that was sent by mistake or must no longer be shown, and if needed, also clean it up from the sent mail history.
-
The app server or client checks the
MailIdof the sent mail to recall. You can use the value saved right after sending as is, and if needed, find it again withGetMailAsync()orGetSentMailsAsync()in Get sent mail. -
Handle the mail recall result. If you receive a success response, the sent mail status immediately changes to
Revoked, and the recall of received mail proceeds asynchronously. If you do not receive a success response, handle it according to the response status in Recall mail. -
Retrieve the mail information again with the same
MailId. If you need to show the latest status again, callGetMailAsync()again to check whetherMailStatusisRevoked, and update the mailbox UI state. To also show whether the mail has expired before deletion, checkExpiresAttogether in this step. -
To immediately hide the recalled sent mail from the sent mail list in the mailbox UI, delete the sent mail. Use the
MailIdsaved right after sending as is, or use theMailIdyou checked again in the previous step. -
Handle the deletion result. If you receive a success response, remove the deleted sent mail from the list and details screens. If you do not receive a success response, handle it according to the response status in Delete sent mail.