We Don’t Know the Origins of the Candy Cane... There are a lot of explanations floating around out there about the candy cane - but almost none of them are true. (1)
"Legend has it that the candy cane dates back to1670, when the choirmaster at the Cologne Cathedral in Germany handed out sugar sticks among his young singers to keep them quiet during the Living Creche ceremony...In honor of the occasion, he bent the candies into shepherds’ crooks.” But it "most likely took shape in 17th centuryEurope when pulled sugars, the parent to today’s sugar sticks, were all the rage. It was at that time, somewhere in Germany, that a hook was added to the stick... likely...to hang them from trees, alongside cookies, fruits and other treats " (2) "No one has yet produced any documentation that either verifies this account as true or reliably dates it to the 17th century — it exists only in the form of anecdote, recorded no earlier than the mid-20th century." (3)
English-language references to “candy canes” (1866) and their association with Christmas (1874) didn’t begin to pop up until the latter part of the 19th century, two hundred years after the treat had supposedly been invented and popularized as a Christmastime confection. (3)
“Legend has it that the candy cane dates back to 1670, when the choirmaster at the Cologne Cathedral in Germany handed out sugar sticks among his young singers to keep them quiet during the Living Creche ceremony,” Schildhaus says. “In honor of the occasion, he bent the candies into shepherds' crooks.” (History.com)
In the early 17th century, Christians in Europe began adopting the use of Christmas trees during their Christmas holidays.
Trees were often decorated with foods such as biscuits and sometimes candy. The original Christmas tree candy was a straight, completely white cane.
Candy Stick becomes a candy cane
The first known historical reference to the reed shape, however, dates back to 1670. The worship choir at Cologne Cathedral in Germany first bent the cane-shaped sugar sticks to represent a pastor's staff. All the white candy canes were then given to the children during the long-term birth services.
The custom of clerics distributing sticks during Christmas services would spread to Europe and later to America. At that time, the sticks were still white, but sometimes candy makers would add sugar roses to further decorate the sticks. In 1847, the first historical reference to the candy cane in America appeared when a German immigrant named August Imgard decorated the Christmas tree in Wooster's home in Ohio with candy canes.
Depending on interpretation
If the question in general is about candy canes then trhere is al legend that it was made in 1670 first time, in Cologne Germany.
Recors of stik candy were in 1837 , also in 1848 there is a mention of a swet candy in Ohio wamde by a Sewwdish-German immigrant.
Speeking about Danes, then it might be tricky, the tradition with christmas tree began to appear in 1800's and it would have been decorated with sweets, but given the fact that in the song, which was written in 1848 there is no mention of candy cane, event though there is the vers " må du gerne gnave" whisch google translates as " feel free to gnaw" so it might suggest it then probably it wasn't a common knowledge/tradition and it appeared later.