When ammonium chloride is heated and rubbed with the metal, the ammonia formed removes grease, oil, etc. It emulsifies fats, grease, etc.

The hydrogen chloride formed removes the oxides of metals and thus cleans the metal surfaces before soldering, tinning, etc.