It seems like the iPhone is thinking that it's connected to a dock connector or it have a jack in, try blowing some air in the dock and in the jack port and see if it helps or not. My iPhone will display that message only when i connect a cable to it and mirroring to the tv, or connect in a jack of a loud speaker.