Apple Inc. (AAPL) chief Tim Cook and Google CEO Sundar Pichai both spoke at a state-run internet conference in China for the first time ever on Sunday, marking Silicon Valley's latest attempts to curry favor with regulators there. 

Cook gave a keynote speech at China's World Internet Conference on Sunday, during which he spoke about the importance of an open internet and detailed how Apple has contributed to the Chinese economy. Top members of the Chinese Communist Party also attended the conference, now in its fourth year, which promoted the idea of cyber sovereignty -- the idea that individual states should be allowed to govern and regulate their own citizens' usage of the internet. 

"The theme of this conference, 'developing a digital economy for openness and shared benefits,' is a vision we at Apple share," Cook said at the conference. "We are proud to have worked alongside many of our partners in China to help build a community that will now join a common future in cyberspace." 

Apple's CEO has many reasons to stay in the Chinese government's good graces. China is Apple's third-largest market, behind North America and Europe, and accounted for roughly 20% of its revenue in fiscal 2017. The iPhone maker also faces tough competition from local smartphone vendors in China such as Huawei, Oppo and Vivo, as well as from local tech giants such as Alibaba Group Holding Ltd. (BABA) , Tencent Holdings Ltd. (TCEHY) and Baidu (BIDU) , who together control a huge proportion of the Chinese internet market. 

China has also become an increasingly important player in Apple's app developer ecosystem. Chinese developers have already earned more than 112 billion yuan ($16.9 billion) on Apple's App Store platform, Cook noted, more than any other country in the world.  

Greater China now ranks as Apple's third-largest market in terms of revenue.
Greater China now ranks as Apple's third-largest market in terms of revenue.

Despite fierce competition that has slowed its growth rate considerably in recent years, Apple has seen its outlook improve in China. During the most recent quarter ended Sept. 30, revenue in Greater China increased 12% year-over-year to $9.8 billion. Wall Street has also become increasingly bullish about Apple's prospects in the region, including Morgan Stanley analyst Katy Huberty, who wrote in a note on Friday that the iPhone's "best days in China are still ahead." 

"Even after recent smartphone user base share gains, we believe that Apple is just turning the corner in China and growth will meaningfully accelerate in quarters to come, due to a litany of factors," Huberty said. "If we are correct, then we believe China could grow over 70% and account for 25% of Apple revenue in fiscal 2018, similar to the last iPhone supercycle in fiscal 2015." 

Like many Silicon Valley giants, Apple has been walking a fine line between meeting Chinese regulators' demands and appeasing human rights watchdogs who argue that doing so could set a dangerous precedent.

In July, Apple was forced to bow to regulators and remove some apps from China's App Store. The Ministry of Industry and Information Technology recently issued stricter rules to regulate virtual private networks (VPNs), which allow users to bypass China's "Great Firewall" that restricts access to many internet websites. Apple, which has sought to build better relations with China, removed many of VPN apps from the App Store, saying they included content that's illegal in China. 

Apple also faced issues with Chinese regulators in October limiting the connectivity of the Apple Watch in China, in addition to criticism for removing the New York Times' English-language and Chinese-language news apps from its App Store in China earlier this year. 

Google, for its part, has also been striving to repair its relations with Chinese regulators. The company shut down its local search engine in China in 2010 rather than continuing to be subject to censorship, although the Alphabet Inc. (GOOGL) unit still sells ads there. In addition to search, Gmail and YouTube also are not available in mainland China. Recently, however, CEO Pichai has spearheaded efforts by Google to regain a presence there, saying he wants "to be in China serving Chinese users." 

"A lot of work Google does is to help Chinese companies," Pichai told delegates at the World Internet Conference on Sunday. "Many small and medium-sized businesses in China take advantage of Google to get their products to many other countries outside of China." 

Cook closed out his keynote address by emphasizing the importance of openness and security in technologies such as the internet and artificial intelligence. 

"Much has been said about the potential downsides of artificial intelligence, but I don't worry about machines thinking like humans. I worry about people thinking like machines," Cook explained. "We all have to work to infuse technology with humanity, with our values."

Apple and Alphabet are holdings in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells AAPL or GOOGL? Learn more now.

More of What's Trending on TheStreet:

More from Stocks

Abercrombie & Fitch CEO: We Aren't the Same Abercrombie You Once Knew

Abercrombie & Fitch CEO: We Aren't the Same Abercrombie You Once Knew

3 Things We Just Learned About Chip Stocks -- and It's Not All Bad News

3 Things We Just Learned About Chip Stocks -- and It's Not All Bad News

Chipotle's New CEO Has Set its Path for Redemption

Chipotle's New CEO Has Set its Path for Redemption

Will China Save Tesla?

Will China Save Tesla?

Facebook First-Quarter Earnings Live Blog

Facebook First-Quarter Earnings Live Blog