You can protect yourself from this by using apps that do not require Google or Apple services. Also avoid alternatives such as microG if you have your own operating system installed. For example, install apps from F-Droid that do not require these services. Some messengers such as Signal offer their own alternatives for centralized push messages.