Skill Level: Any
Not what youâ€™re looking for? Check out all our available tutorials for mobile app messaging here.
Removing and hiding expired messages
When the server cleans up the messages it marks them as deleted, and only removes them from itâ€™s storage after that deleted flag is synced to the device. When the device is syncing with the server, it will pick up these deleted flags and remove the messages from itâ€™s local store even without calling the clearExpiredMessages method.
Users will see expired messages for 30 days after the expiration date, and then these messages are automatically purged by the server. This is useful for showing users what they missed (perhaps by dimming the message or marking it as â€śexpiredâ€ť).
Under other circumstances, you may want to delete all expired messages and prevent them from being presented to users.
To delete all expired messages add the following in the app startup code:
To hide expired messages from a user, uncomment the code in MCEInboxDefaultTemplate.m shouldDisplayInboxMessage:
Modifying inbox templates
Adjusting the look and feel of the inbox templates:
The inbox we ship is configurable so that you can have it appear the way you want it. Suppose your other UI uses the Times Roman font with a white foreground color and a red background color. You may want your inbox messages to show up in the list with similar styling.
- In the Default template edit the .xib files in the Default Template Handler directory to match the desired style using the Interface Builder GUI.
- In the Post template edit the .xib files in the Post Template directory to match the desired style using the Interface Builder GUI.
Changing the â€ścontainerâ€ť for inbox messages:
The MCEInboxTableViewController can be adjusted to look how you wish. Both the container and the inbox templates are adjusted using a combination of adjusting the xib/storyboard as well as adjusting the code.
Show a background image rather than setting the color
To use an image as your background instead of a color:
- In the Default Template Handler directory, edit the .xib files to match the desired style using the Interface Builder GUI.
- In the Post template directory edit the .xib files to match the desired style using the Interface Builder GUI.
Changing the inbox sort order
Other than by default, You may want to sort the inbox in a different order. For instance, you might want to sort using a custom field rather than by sendDate.
The simplest way to change the sort order would be to use the standard Swift Array sort method.Â
Inbox with different behaviors depending on different kinds of messages received
To set different behaviors based on the kinds of inbox messages received (e.g., play a sound when special offers are opened but not regular messages):
To designate particular sounds for specific messages, for example, add a custom field to the inbox message itself. The best place to act on that custom field would be in the presentation layer for the specific template that will be used. If one were using a default template and wanting to play a sound when the message was opened, a custom field could be added called “sound”. Then, leave it blank or do not include it if no sound is to be played and specify a filename when a sound should be played:
Need more help? Check out all of our available tutorials for mobile app messaging here.