What is the theory behind the coded magnet sensor?
The idea of a "coded magnet" is nothing more than an array of magnets with a distinct combination of magnet polarities and magnetic intensities. This makes a more complex and unique magnetic field than just a single regular magnet. The receiver knows which type of magnetic field to expect and thus can accept/reject foreign magnet patterns.

Take a look at this image for a rough example of a type of coded magnets.(Image source: patentlyapple.com)

This image shows an example of a unique spatial arrangement of magnet polarities and intensities.  The numbers (600 and 800) represent that particular magnets intensity.

As you can see, this generates a unique magnetic field.

If you would like additional information, take a look at the Wikipedia page. http://en.wikipedia.org/wiki/Programmable_magnet