Documents published by the Intercept reveal the range of information the authorities can get USA by the service messages Apple's iMessage (now renamed Message) via court orders.
Because all iMessage content is end-to-end encrypted, not even Apple itself can access the actual talks. However, iMessages also contain some metadata that is sent and stored on Apple's servers.
For example, Apple records every new conversation that users are trying to get started with. Whenever a user enters one person's phone number through the application, iMessage sends the information to Apple's servers to determine if the other number belongs to a user who owns the iMessage application or not. This information is used before the beginning of each conversation via iMessage messages or the default SMS application on the phone.
So Authorities with judgments using this data can find out who someone has spoken to, date, time, and IP address.
Metadata does not mean that they indicate that a conversation took place, but they certainly indicate that the user at least tried to communicate with the other party.
In addition, because the data stored is recorded and the IP of the user, the Authorities or someone else can determine the geographic position of the user based on its IP.
Apparently Apple lied about not storing such data in 2013 when Edward Snowden first publicized the NSA scandal. He then revealed that Apple was allowing the NSA to collect metadata from its service.
The company said in a statement following Snowden's revelations that "we do not store customer location data, map searches or Siri requests in any identifiable format."
The documents published by Intercept are called "iMessage FAQ for Law Enforcement,” and is sort of a handbook detailing what kind of data can be collected by Apple. These files clearly show that Apple does collection location information in the form of IP, contrary to previous statements by the company.