You record into GarageBand iOS using the new IAA (Inter-App Audio) standard.Your MIDI keyboard has to be connect to your iPhone (see previous post).The only way i can think of is the following:: 'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'
I explain in great details how to make all that work in my manuals " GarageBand X - How it Works" and "Logic Remote - How it Works", the only comprehensive books available for those two apps. This is really cool, and you can use some of the unique smart instrument touch interfaces.
If you download the free Logic Remote app for iOS (it works with GarageBand despite the "Logic" name), you can actually play your GarageBand instrument via Wi-Fi using the touch interface on iPad (sorry not for iPhones). The M Audio website should tell you that. Check in the Audio MIDI Setup utility if your system recognizes the Keyboard, or if you need a Driver. To connect the M Audio to your iMac, just connect it to the USB port (I guess the M audio has a USB port too). For your iPhone, you need a MIDI to Lightning connector interface.