Oli Dunkley/Flickr The employee that Ryley Smith threatened at knifepoint was actually a “friend” of his on Facebook.

Police in Canada caught a masked armed robber after he unfriended his victim on Facebook.

Ryley Smith, 20, stole about US$750 when he held up a Subway sandwich store in Moncton, New Brunswick, on Nov. 12, 2014, Canadian Press reports.

But the employee that he threatened at knifepoint was actually a "friend" of his on the social networking site.

Smith's disguise masked his identity, but the robber's victim became suspicious after he deleted him as a friend after the heist.

The Royal Canadian Mounted Police matched Smith's DNA to a sample taken from a bandana found dumped in the restaurant's parking lot.

Authorities issued a country-wide warrant for Smith's arrest and he was eventually detained in Calgary, Alberta, in November 2015.

He was sentenced to three-and-a-half years in prison after pleading guilty to robbery at a court in Moncton on Wednesday.