how much of all of this logic is the same as for ios? could any code be cleanly shared?