On iOS, the Messages app has an option in Settings > Notifications > Messages called "Show Previews".
This changes the notification text depending on whether the phone is unlocked. For example, when my phone is locked the notification appears as:
John Smith
iMessage
But when I look at the same message in notification centre later the full message text is displayed:
John Smith
Nice to see you yesterday...
WhatsApp has a similar setting for "Show Preview" but doesn't have the same behaviour as Messages. The preview is always "Message from John Smith"
Is it possible for 3rd party apps to implement similar functionality to the Messages app? Is Apple using a private API to do this?