The teen victim was chatting on his iPhone when Robert Ferguson and Mark Edward Taylor walked up to the vehicle, parked in Eastfield, and let themselves in.
Ferguson, 22, then put the terrified victim in a headlock and punched him, before wrestling the phone off him, York Crown Court heard.
The pair ran off but were later identified after the victim, who cannot be named for legal reasons, tracked them down on Facebook.
They were arrested and charged with robbery. Both men, from Eastfield, initially pleaded their innocence, but later admitted the offence and appeared for sentence on Friday.
Prosecutor Helen Chapman said Ferguson, who has previous convictions for robbery, was the main player in the incident, which occurred at about 10pm on September 27 last year.
She said the victim was one of two passengers in a car driven by his cousin. The vehicle parked up on the street in Merrydale, where Ferguson and Taylor, also 22, saw an opportunity because the front passenger-seat window was partly open and the teenager was using an expensive iPhone 5S.
Ferguson demanded the victim hand over the phone but the teenager refused, whereupon the robber opened the passenger door and got inside.
“He (Ferguson) asked for the phone again and when (the victim) refused, he was held in a headlock by Ferguson and punched by both men,” said Ms Chapman.
“One of the defendants then took the phone from him. They left, but later that evening (the victim) looked on Facebook and was able to identify both defendants.”
Police were informed and the robbers were picked out in an ID Parade by the victim and his cousin.
Mrs Chapman said the phone was never recovered and the victim suffered bruising to his face as a result of being punched.
The court was told that Ferguson had previous convictions for burglary, theft from the person, affray, assault and public disorder. His two previous robbery convictions were in 2007 and 2012, the latter involving the use of a knife and resulting in three years’ detention in a young-offenders’ institution.
Patricia Doherty, for Ferguson, said her client claimed he was on a cocktail of prescription drugs for mental-health issues at the time and had no recollection of the incident, but eventually accepted the prosecution case.
Chris Dunne, for Taylor, said the father-of-one played a “peripheral” role in the robbery and was not a violent man despite previous convictions for burglary, handling stolen goods and public disorder.
Judge Guy Kearl QC slammed the two men for lying to police, providing false alibis and putting the victim through an “extremely-frightening experience”.
He jailed Ferguson, of Dale Edge, for two years and eight months. Taylor, of High Garth, was jailed for two years.