While Apple’s position in China is about as different from Facebook’s as possible — it has built a hugely valuable retail business — it too has been affected by the law. Just the week before WhatsApp was hit by disruptions, Apple said that to ensure it complied with the law it would begin storing data from its iCloud service in China. It also said it would work with a local Chinese company to set up a data center in southwest China as part of a $1 billion investment.

An Apple spokeswoman referred to remarks by Apple’s chief executive, Timothy D. Cook, during the company’s most recent earnings call, in which he said Apple was “very enthusiastic” about opportunities in China.

Yet keeping Beijing satisfied is only part of the challenge for Apple. With more and more Chinese smartphone makers selling high-quality smartphones cheaply, the company’s sales in the country have slid over the past two years. In the second quarter ending April 1, the company’s revenue in greater China fell 14 percent, even as the market remains critical. Greater China accounts for 21 percent of the company’s sales, making it Apple’s most important market after the United States.

In a new tack for Apple in China, just last week it created a new position, general manager for greater China, and appointed a longtime manager, Isabel Ge Mahe, to the position. Ms. Ge Mahe was born in China, speaks Mandarin and has deep engineering experience. The company is also in search of a greater China policy head after its former head, Jun Ge, recently resigned, according to two people familiar with the matter.

If Apple is trying something new, LinkedIn is showing that what had been an accepted model within China is no guarantee of success. Unlike Apple, which as a hardware company is considered less threatening by the Chinese government, LinkedIn had to go along with a bargain other internet companies have refused.

In 2014 the company agreed to start censoring — much as Google had done almost a decade before it eventually left China — and formed a partnership with two influential Chinese venture capital investment funds to create a separate China operation. While the self-censorship drew complaints from users, other technology companies looking to get into China came to see LinkedIn’s approach as a model.

By bringing in well-connected investors, it was able to ensure its communications with the Chinese government were in capable hands. It also focused on the particulars of the local market. It hired Derek Shen, a successful Chinese entrepreneur and Google veteran, to run its China operations separately. Mr. Shen, in turn, created a stand-alone app to bring LinkedIn, a service built around email and computers, to China’s smartphone-dependent population.