New York CNN Business  — 

At one time, the staggering success of the iPhone helped catapult Apple to become the world’s most valuable company. Now, its lackluster smartphone sales are dragging down Apple’s business.

Apple (AAPL) said Tuesday that its revenue for the first three months of 2019 declined 5% from the year prior to $58 billion as it grappled with sluggish smartphone demand. iPhone sales for the period fell 17% from the year prior.

For years, Apple’s iPhone business appeared to defy gravity as the company managed to sell more devices and gradually charge more for them. But that narrative was shattered at the beginning of this year when the company warned investors that iPhone sales had taken a hit from a slowdown in China amid an ongoing trade war.

However, on a conference call with analysts after the earnings report Tuesday, CEO Tim Cook signaled that the worst may be over for the iPhone as Apple sees signs of improvement in China. In particular he cited “improved trade dialogue” between China and the United States and “very positive customer response to the pricing actions we’ve taken in that market.”

Apple has faced stiff competition in China from competitors like Huawei and Xiaomi, which offer cheaper smartphones at a time when Apple is embracing phones with four-figure price tags. Apple recently reduced the price of some of its products, including the iPhone XS and XR, by nearly 6% in some instances.

Still, Apple has a long way to go to start growing again in China, which was not long ago viewed as one of its most promising markets. Apple posted revenue of $10.2 billion in China for the first three months of the year, down 21% from $13 billion in the same period a year ago.

“While China continues to be soft, it appears Apple saw strength in the last few weeks of the quarter across the board on a rebound in iPhone demand,” Daniel Ives, an analyst with Wedbush, wrote in an investor note Tuesday after the report.

Looking back at the last five months, Cook said “November and December were the most challenging.” Cook added: “Our goal now is to pick up the pace.”

During the most recently completed quarter, Apple offset some of its iPhone declines with continued growth in its digital services business. The services segment, which includes products such as Apple Pay, Apple Care and Apple Music, generated a record $11.5 billion in revenue during the quarter, a 16% increase from a year ago. It is currently Apple’s second biggest revenue driver, ahead of the Mac and iPad.

Apple is looking to grow this segment even more: last month it held a splashy, celebrity-filled press event to unveil multiple new paid subscription services.

The growth in services helped push Apple’s overall revenue above Wall Street’s muted expectations. Apple also appeased investors by announcing plans to repurchase another $75 billion worth of shares and increasing its dividend.

Apple stock rose 5% in after-hours trading Tuesday following the earnings report.