Image copyright Xinhua/Alamy Live News Image caption Beijing realised the importance of cultivating relations with Mr Trump's family

It's been a month and adjusting to Donald Trump as US president has been an enormous challenge for China, as for many around the world.

He arrived in office full of provocative and unpredictable messaging on China, but Beijing needs American goodwill, markets and technology to build what it calls its "comprehensive strength".

That a functioning relationship with the United States is a core strategic interest for China may seem obvious, but it bears repeating.

For the time being at least Mr Trump seems to have stopped insulting and threatening China - despite repeating on Friday that he thought they were "grand champions at manipulation of currency". Key players in Mr Trump's administration are now making nice on the telephone.

So what were China's tactics and how did it make them work?

1. Cultivate family, cultivate friends

Beijing quickly understood that President Trump would not run an administration like that of his predecessors.

Image copyright EPA Image caption Mr Trump is an elephant in a China shop for the makers of this float in Germany

It noted the importance of family.

Before Mr Trump himself or senior members of his administration talked to key players in China, and while China's internet was full of mutterings about why Mr Trump had delivered no goodwill message over Chinese New Year, Beijing's man in Washington, Ambassador Cui Tiankai, deftly reached out to President Trump's daughter Ivanka.

She bridged the official divide with a well-publicised appearance at a Chinese New Year function at Beijing's embassy in Washington.

Ivanka's husband Jared Kushner also has lines of communication to Beijing through his Chinese business partners.

And President Trump's other daughter Tiffany made a point of sitting in the front row of the New York Fashion Week show of Chinese designer Taoray Wang.

Image copyright Getty Images Image caption Ms Wang and Tiffany Trump have praised each another

To bolster this network of unofficial connections, China's best known private entrepreneur Jack Ma, met Mr Trump and promised to create a million American jobs through selling US products on his Alibaba e-commerce platforms.

Even private companies in China have Communist Party cells and are required to do Beijing's bidding when it comes to matters of strategic national interest.

Jack Ma was on mission and on message. As were the 100 firms which sponsored a Chinese New Year greeting message to Mr Trump on a Times Square billboard in New York.

2. Bring gifts

Mr Trump's controversial business empire has multiple trademark cases languishing in Chinese courts.

Beijing makes no bones about the fact that its courts are answerable to the Communist Party.

It was an easy act of goodwill to speed through a trademark registration for construction services that Mr Trump had sought for a decade, especially as the move was consistent with a wider move against businesses which jump on the names of public figures as trademarks.

Image copyright Chinatopix/AP Image caption After years of wrangling, Chinese courts awarded Mr Trump valuable commercial rights to his name

In the Trump case, the necessary moves were made quickly and without fanfare last autumn, and the case closed with a victory for Mr Trump last week.

3. Speak softly until you need to speak loud

China is often quick to thunder against hostile foreign forces and accuse foreign governments of hurting the feelings of the Chinese people.

Donald Trump offered provocations which would bring down retribution on a lesser foe.

Throughout his presidential campaign he insulted and threatened China, calling it a thief and a rapist on trade and challenging its dearest held positions on Taiwan. Officials also warned of a tougher approach in the South China Sea.

But throughout, Beijing has shown iron self-discipline and restraint.

Image copyright Getty Images Image caption China claims almost all the South China Sea, a position the US rejects

China's official news agency Xinhua noted of Mr Trump: "He will soon realise that leaders of the two countries must use more mature and effective ways to communicate than trading barbs via Twitter."

Since Mr Trump's election in November, China's media has been on a tight leash, ordered to use Xinhua's bland wording in its coverage of the US.

4. Don't speak until the script is agreed

Unlike other world leaders, President Xi was conspicuously slow to pick up the phone.

Observing the fallout of President Trump's calls with Mexican and Australian leaders, Beijing was determined to avoid the risk of an undiplomatic incident.

By hanging back till the administration's "grown ups" like Defence Secretary James Mattis and Secretary of State Rex Tillerson were in the room (figuratively and in some cases literally) China ensured it got the script it wanted.

Image copyright AP Image caption The two leaders did not speak until long after many other leaders had called Mr Trump

When the phone call between President Trump and President Xi finally took place, Beijing won a new US commitment to the cherished One China policy and a dignified encounter.

President Xi emerged with his reputation as a firm and patient actor enhanced. President Trump had talked of staking out a new position on Taiwan - but stepped back.

5. Sweet talk where it pays

Since that call, the lines between Beijing and Washington DC have been humming.

Newly confirmed US Treasury Secretary Steve Mnuchin has talked to several key Chinese players on economic policy. Mr Tillerson has met his opposite number, Wang Yi, and senior diplomat Yang Jiechi.

Beijing has begun to talk of implementing "the consensus reached between President Xi and President Trump" - a relationship featuring "no conflict, no confrontation, mutual respect and win-win co-operation".

6. Give what you can

In practical terms, China knows that win-win will mean delivering concessions and co-operation wherever it can. And it has already shown willing in one area of US concern, with the suspension of coal imports from North Korea.

Image copyright AFP Image caption By suspending coal imports, China has put pressure on Pyongyang

Of course, Beijing said this decision was a technicality based on quotas.

But given the provocation of Pyongyang's latest missile test and growing American concern over the advances of North Korea's nuclear programme, this is much more likely to have resulted from a careful Chinese calculation of what carrots it could flourish in the direction of Donald Trump and what sticks it could brandish at Kim Jong-un.

7. Turn your opponent's weakness into your strength

On the global stage, President Xi has usefully presented himself as not Donald Trump.

At the World Economic Forum in Davos, he famously championed globalisation and free trade.

Of course, China is not a paragon of free trade, with a highly protected domestic market. But in a world of "alternative facts", the rhetoric is powerful.

On the regional stage, China is promoting itself as a leader on multilateral trade, assiduously taking advantage of the US withdrawal from the Trans-Pacific Partnership (TPP) deal, which was intended to underpin American economic leadership in Asia Pacific.

Image copyright Getty Images Image caption Although the TPP excluded China, it had opponents across the political spectrum in the US

And on the Chinese political stage, Mr Trump is indirectly doing Mr Xi's work for him.

The Communist Party sometimes struggles to defend one-party authoritarian rule against the glamour and appeal of a free, open and democratic America. But the scenes of American street protest and visa chaos from President Trump's first month in office are a propaganda gift.

An American president joining China's state-controlled media in railing against what he calls fake, failing, dishonest US journalists is a second propaganda gift. Beijing has made extensive use of both for its political purposes at home.

Tactics that worked

Beijing will be well satisfied with its performance so far. But this is a multi-player multi-dimensional game with many dangers and traps over the long term.

It has done a good job of neutralising the risks and exploiting the opportunities of President Trump's first month in office.

Round One to China. There are innumerable rounds still to come.