Skip to content

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.

  1. 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.

  2. Send the mail. Set RecipientScope to Direct and put the list of recipient PlayerId values in RecipientPlayerIds. For mail with attached items, put the list of attached items in Attachments.

  3. Handle the mail sending result. If sending succeeds, save the MailId from the response data. You use MailId later 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.

  4. Get sent mail. To check the status of a specific mail item right after sending, call GetMailAsync() with the saved MailId. To also view the sending history or to find the MailId again, use GetSentMailsAsync() to check MailStatus, 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.

  1. The user enters the mailbox screen in the app.

  2. 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.

  3. When the user selects a specific mail item on the mail list screen, call GetReceivedMailAsync() to check the mail body, attached items, MailStatus, TextReadAt, and AttachmentReadAt together. At this time, also pass Language.

  4. When the user reads the body of the selected mail, call MarkMailAsReadAsync() with Target = Text to reflect the body read status.

  5. 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() with Target = Attachment or All to reflect the attached item claim status.

  6. Handle the read result. If you receive a success response, immediately update the mailbox screen state based on TextReadAt and AttachmentReadAt in 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.

  1. The user selects the mail to delete on the mailbox list screen.

  2. The app client checks the MailRecipientId of 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 of GetReceivedMailAsync() as needed.

  3. Delete the received mail.

  4. 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.

  1. The app server or client checks the MailId of the sent mail to recall. You can use the value saved right after sending as is, and if needed, find it again with GetMailAsync() or GetSentMailsAsync() in Get sent mail.

  2. Recall the mail.

  3. 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.

  4. Retrieve the mail information again with the same MailId. If you need to show the latest status again, call GetMailAsync() again to check whether MailStatus is Revoked, and update the mailbox UI state. To also show whether the mail has expired before deletion, check ExpiresAt together in this step.

  5. To immediately hide the recalled sent mail from the sent mail list in the mailbox UI, delete the sent mail. Use the MailId saved right after sending as is, or use the MailId you checked again in the previous step.

  6. 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.

Learn more