A deal has been made between the US and China to keep TikTok running in the US, according to the US President Donald Trump.

We have a deal on TikTok, I've reached a deal with China, I'm going to speak to President Xi on Friday to confirm everything up, Trump told reporters as he left the White House for a state visit to the UK.

The social media platform, which is run by Chinese company ByteDance, was told it had to sell its US operations or risk being shut down. However, Trump has repeatedly delayed the ban since it was first announced in January.

The US president said a buyer will be announced soon. CNBC reported the deal would include a mix of current and new investors and would be completed in the next 30 to 45 days.

It also said US tech company Oracle would keep its existing agreement to host TikTok servers inside the US. That had been one of the main concerns of American lawmakers, who cited concerns over data being shared with China on national security grounds.

On Monday, a US trade delegation said it had reached a framework deal with China amid wider trade negotiations in Madrid. China confirmed a framework agreement but said no deal would be made at the expense of their firms' interests.

After initially calling for TikTok to be banned during his first term, Trump has reversed his stance on the popular video-sharing platform. Despite the concerns raised about national security, ByteDance has maintained that its US operations are separate and do not share information with the Chinese state.

The deadline for a sale has since been extended three times, and the latest delay to the ban is due to end on 17 September.