This application discloses a communications method, and the method includes: receiving, by a terminal device, first information, where the first information is used to indicate one or more first time units in a random access system frame; and determining, by the terminal device, the one or more first time units based on the first information and a configuration table, where one or more time units in the configuration table are determined based on an uplink-downlink configuration period and a second time unit, the one or more first time units are an optional time domain resource of a random access sequence, and the second time unit is an optional time domain resource of a synchronization channel block. According to the method and the apparatus in this application, the optional time domain resource of the random access sequence can be determined.