Apple has suffered another setback in China, a country that's critical to the company's success.

A Beijing intellectual property board ruled that Apple violated the design patents of Shenzhen Baili with the iPhone 6 and iPhone 6 Plus. As a result, the company must stop sales of the two devices in Beijing. The ruling says Apple's iPhone 6 and 6 Plus infringe on patents of Baili's 100C smartphone.

The decision was posted online in May, although it was unclear exactly when the ruling came down. Apple says it's appealing and that the two models are currently still on sale while the order is under review by a court.

The iPhone 6 and iPhone 6 Plus models launched in 2014, and Apple has slowly started to move away from selling them to make way for newer models, such as the iPhone 6S, 6S Plus and SE.

But the decision comes at a crucial time for Apple, which has taken some recent hits from Chinese regulators.

Last month, the company lost a four-year legal dispute to prevent a Chinese manufacturer from using the "iPhone" name on its leather mobile accessories.

In April, Apple's iBooks and iTunes Movies services shut down in China.

"We hope to make books and movies available again to our customers in China as soon as possible," the company said in a statement at the time.

Apple did not cite a reason for the services shutting down. But the decision followed new rules announced in February requiring government approval for foreign companies wanting to provide online content such as videos, games and books.

Related: 30 Chinese Apps you need to know

CEO Tim Cook recently visited Beijing after Apple (AAPL) announced it would invest $1 billion in Didi Chuxing, Uber's biggest rival in Asia. Some see the investment as a way for Apple to smooth its relationship with the Chinese government.

As demand for new mobile phones continues to shrink, Apple has its sights set on China's booming consumer market. But the company has been stumbling in China, seeing sales slide 26% during the first three months of the year -- more than any other market decline.

The main reason for the drag is that the iPhone hasn't been selling as well as Apple has hoped, thanks to China's homegrown brands such as Huawei, Xiaomi, OPPO and vivo.

Huawei is currently the third biggest smartphone vendor in the world and Xiaomi is fifth, according to IDC.