Demodulaion of AM (modulate signal is square wave)
The same technique is used, but you need to know that the bandwidth of your receiver (and of the transmitter) will put limitations on your square wave.  A pure square wave requires infinite bandwidth.  Getting reasonably close requires a wide bandwidth.   So you will probably need to accept a less-then ideal result.

Also, the action of that capacitor will remove the highest frequencies, also distorting a square wave.  You can make the value smaller, but at some point, the carrier signal will start to reappear.