For Android phones/tablets:
You need to access the target device (get it in your hand and unlock it with the password/passcode) and physically install iKeyMonitor on it.
No physical access is needed if you have iCloud ID/Password(disabled 2-factor authentication) of the target iPhone/iPad and iCloud backup is enabled.
But if you have access to the device and it can be jailbroken, you can enjoy more features like screenshot capturing, keylogging and more.
You need to access the target device to install the spy app. Administrator password may be required when you install it.