According to the Crown Prosecution Service's legal guidance Disclosure – Guidelines on Communications Evidence (26 January 2018), the law is that:
Investigating officers are required to pursue all reasonable lines of inquiry, whether to exonerate or implicate suspects … This will often include the obtaining and analysis of communication evidence whether it originates from devices or social media accounts belonging to the complainant or the suspect or, in some cases, to third parties.
See also Disclosure – A guide to "reasonable lines of enquiry" and communications evidence (24 July 2018):
The examination of mobile devices belonging to the complainant is not a requirement as a matter of course in every case. There will be cases where there is no requirement for the police to take the media devices of a complainant or others at all … Examples of this would include sexual offences committed opportunistically against strangers, or historic allegations where there is considered to be no prospect that the complainant’s phone will retain any material relevant to the period in which the conduct is said to have occurred and/or the complainant through age or other circumstances did not have access to a phone at that time.
There is an extensive discussion of the "issues of principle … that frequently arise in present-day police investigations … linked to the privacy concerns of complainants and other witnesses who are asked by the police to share the contents of their mobile telephones" in Bater-James v The Queen  EWCA Crim 790 (23 June 2020), from paragraph 65 onwards. The end-to-end rape review report on findings and actions (June 2021), at paragraphs 93 – 101, cites this decision and commits the Government to ensuring that:
No victim is left without a phone for more than 24 hours … and victims are not asked for information unless it is necessary and proportionate in pursuit of a reasonable line of inquiry.
The most recent Rape Review progress update (June 2022), at pages 11 – 12, summarises recent reform in this area, including changes to police practice and passage of the Police, Crime, Sentencing and Courts Act 2022. Chapter 3 of Part 2 of that Act introduces new powers to extract information from electronic devices with the user's informed consent. However, as noted at paragraph 22 of the new Code of practice: Extraction of information from electronic devices (17 October 2022), these powers are distinct from existing "coercive or compulsory powers, such as a search warrant, production order or statutory notice."