Only receive notifications of messages under locked state

If you want your iPhone only to receive notifications but not to display the message contents under locked state, here is the solution:
settings – notifications – messages – turn off Show Preview