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?
This is possible for all apps in iOS 11 without the app developer taking any action. iOS 11 introduces a new option in the notification settings:
Settings > Notifications > Application > Show Previews > When Unlocked
How to Hide Text Previews for Every App Notification on iOS 11's Lock Screen - MacRumors
I'd still be interested to hear if there's any way for an app to customise the text that appears when locked. It seems to be just "Notification".